ansible / ansible.builtin / v2.7.9 / module / gce_labels Create, Update or Destroy GCE Labels. | "added in version" 2.4 of ansible.builtin" Authors: Eric Johnson (@erjohnso) <erjohnso@google.com> preview | supported by communityansible.builtin.gce_labels (v2.7.9) — module
pip
Install with pip install ansible==2.7.9
Create, Update or Destroy GCE Labels on instances, disks, snapshots, etc. When specifying the GCE resource, users may specifiy 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 documentaion. 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) 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) 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 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
labels: description: - A list of labels (key/value pairs) to add or remove for the resource. required: false resource_url: description: - The 'self_link' for the resource (instance, disk, snapshot, etc) required: false resource_name: description: - The name of resource. required: false resource_type: description: - The type of resource (instances, disks, snapshots, images) required: false resource_location: description: - The location of resource (global, us-central1-f, etc.) required: false
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