community.google.gce_tag module – add or remove tag(s) to/from GCE instances
Note
This module is part of the community.google collection (version 1.0.0).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install community.google
.
To use it in a playbook, specify: community.google.gce_tag
.
Synopsis
This module can add or remove tags https://cloud.google.com/compute/docs/label-or-tag-resources#tags to/from GCE instances. Use ‘instance_pattern’ to update multiple instances in a specify zone.
Requirements
The below requirements are needed on the host that executes this module.
python >= 2.6
apache-libcloud >= 0.17.0
Parameters
Parameter |
Comments |
---|---|
The name of the GCE instance to add/remove tags. Required if |
|
The pattern of GCE instance names to match for adding/removing tags. Full-Python regex is supported. See https://docs.python.org/2/library/re.html for details. If |
|
Path to the PEM file associated with the service account email. |
|
Your GCE project ID. |
|
Service account email. |
|
Desired state of the tags. Choices:
|
|
Comma-separated list of tags to add or remove. |
|
The zone of the disk specified by source. Default: “us-central1-a” |
Examples
- name: Add tags to instance
community.google.gce_tag:
instance_name: staging-server
tags: http-server,https-server,staging
zone: us-central1-a
state: present
- name: Remove tags from instance in default zone (us-central1-a)
community.google.gce_tag:
instance_name: test-server
tags: foo,bar
state: absent
- name: Add tags to instances in zone that match pattern
community.google.gce_tag:
instance_pattern: test-server-*
tags: foo,bar
zone: us-central1-a
state: present
Authors
Do Hoang Khiem (@dohoangkhiem) <(>
Tom Melendez (@supertom)