New in version 2.4.
parameter | required | default | choices | comments |
---|---|---|---|---|
labels | no | A list of labels (key/value pairs) to add or remove for the resource. | ||
resource_location | no | The location of resource (global, us-central1-f, etc.) | ||
resource_name | no | The name of resource. | ||
resource_type | no | The type of resource (instances, disks, snapshots, images) | ||
resource_url | no | The 'self_link' for the resource (instance, disk, snapshot, etc) |
- 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
Common return values are documented here Return Values, the following are the fields unique to this module:
name | description | returned | type | sample |
---|---|---|---|---|
state | state of the labels | Always. | str | present |
resource_name | The name of the GCE resource. | Always. | str | my-happy-little-instance |
resource_url | The 'self_link' of the GCE resource. | Always. | str | https://www.googleapis.com/compute/beta/projects/myproject/zones/us-central1-f/instances/example-instance |
labels | List of labels that exist on the resource. | Always. | dict | [{'environment': 'test', 'webserver-frontend': 'homepage', 'environment-name': 'kennedy'}] |
resource_type | The type of the GCE resource. | Always. | str | instances |
resource_location | The location of the GCE resource. | Always. | str | us-central1-f |
Note
This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.
For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Testing Ansible and Developing Modules.
© 2012–2017 Michael DeHaan
© 2017 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/gce_labels_module.html