community / community.google / 1.0.0 / module / gce_labels Create, Update or Destroy GCE Labels. Authors: Eric Johnson (@erjohnso) <erjohnso@google.com>community.google.gce_labels (1.0.0) — module
Install with ansible-galaxy collection install community.google:==1.0.0
collections: - name: community.google version: 1.0.0
Create, Update or Destroy GCE Labels on instances, disks, snapshots, etc. When specifying the GCE resource, users may specify the full URL for the resource (its 'self_link'), or the individual parameters of the resource (type, location, name). Examples for the two options can be seen in the documentation. See U(https://cloud.google.com/compute/docs/label-or-tag-resources) for more information about GCE Labels. Labels are gradually being added to more GCE resources, so this module will need to be updated as new resources are added to the GCE (v1) API.
- name: Add labels on an existing instance (using resource_url) community.google.gce_labels: service_account_email: "{{ service_account_email }}" credentials_file: "{{ credentials_file }}" project_id: "{{ project_id }}" labels: webserver-frontend: homepage environment: test experiment-name: kennedy resource_url: https://www.googleapis.com/compute/beta/projects/myproject/zones/us-central1-f/instances/example-instance state: present
- name: Add labels on an image (using resource params) community.google.gce_labels: service_account_email: "{{ service_account_email }}" credentials_file: "{{ credentials_file }}" project_id: "{{ project_id }}" labels: webserver-frontend: homepage environment: test experiment-name: kennedy resource_type: images resource_location: global resource_name: my-custom-image state: present
- name: Remove specified labels from the GCE instance community.google.gce_labels: service_account_email: "{{ service_account_email }}" credentials_file: "{{ credentials_file }}" project_id: "{{ project_id }}" labels: environment: prod experiment-name: kennedy resource_url: https://www.googleapis.com/compute/beta/projects/myproject/zones/us-central1-f/instances/example-instance state: absent
state: choices: - present - absent default: present description: The state the labels should be in. C(present) or C(absent) are the only valid options. required: false type: str labels: description: - A list of labels (key/value pairs) to add or remove for the resource. required: false type: dict pem_file: description: - The path to the PEM file associated with the service account email. - This option is deprecated and may be removed in a future release. Use I(credentials_file) instead. type: str project_id: description: - The Google Cloud Platform project ID to use. type: str resource_url: description: - The 'self_link' for the resource (instance, disk, snapshot, etc) required: false type: str resource_name: description: - The name of resource. required: false type: str resource_type: description: - The type of resource (instances, disks, snapshots, images) required: false type: str credentials_file: description: - The path to the JSON file associated with the service account email. type: str resource_location: description: - The location of resource (global, us-central1-f, etc.) required: false type: str service_account_email: description: - service account email type: str service_account_permissions: description: - service account email type: list
labels: description: List of labels that exist on the resource. returned: Always. sample: - environment: test environment-name: kennedy webserver-frontend: homepage type: dict resource_location: description: The location of the GCE resource. returned: Always. sample: us-central1-f type: str resource_name: description: The name of the GCE resource. returned: Always. sample: my-happy-little-instance type: str resource_type: description: The type of the GCE resource. returned: Always. sample: instances type: str resource_url: description: The 'self_link' of the GCE resource. returned: Always. sample: https://www.googleapis.com/compute/beta/projects/myproject/zones/us-central1-f/instances/example-instance type: str state: description: state of the labels returned: Always. sample: present type: str