On this page
gce_tag - add or remove tag(s) to/from GCE instances
New in version 2.0.
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 (on host that executes module)
- python >= 2.6
- apache-libcloud >= 0.17.0
Options
parameter | required | default | choices | comments |
---|---|---|---|---|
instance_name |
no |
The name of the GCE instance to add/remove tags. Required if instance_pattern is not specified.
|
||
instance_pattern
(added in 2.3)
|
no |
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 instance_name is not specified, this field is required.
|
||
pem_file |
no |
path to the pem file associated with the service account email
|
||
project_id |
no |
your GCE project ID
|
||
service_account_email |
no |
service account email
|
||
state |
no | present |
|
desired state of the tags
|
tags |
yes |
comma-separated list of tags to add or remove
|
||
zone |
no | us-central1-a |
the zone of the disk specified by source
|
Examples
# Add tags 'http-server', 'https-server', 'staging' to instance name 'staging-server' in zone us-central1-a.
- gce_tag:
instance_name: staging-server
tags: http-server,https-server,staging
zone: us-central1-a
state: present
# Remove tags 'foo', 'bar' from instance 'test-server' in default zone (us-central1-a)
- gce_tag:
instance_name: test-server
tags: foo,bar
state: absent
# Add tags 'foo', 'bar' to instances in zone that match pattern
- gce_tag:
instance_pattern: test-server-*
tags: foo,bar
zone: us-central1-a
state: present
Notes
Note
- Either instance_name or instance_pattern is required.
Status
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–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.4/gce_tag_module.html