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
The below requirements are needed on the host that executes this module.
- python >= 2.6
- apache-libcloud >= 0.17.0
Parameters
Parameter | Choices/Defaults | Comments |
---|---|---|
instance_name
-
|
The name of the GCE instance to add/remove tags.
Required if instance_pattern is not specified.
|
|
instance_pattern
-
added in 2.3
|
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
-
|
Path to the PEM file associated with the service account email.
|
|
project_id
-
|
Your GCE project ID.
|
|
service_account_email
-
|
Service account email.
|
|
state
-
|
|
Desired state of the tags.
|
tags
- / required
|
Comma-separated list of tags to add or remove.
|
|
zone
-
|
Default:
"us-central1-a"
|
The zone of the disk specified by source.
|
Notes
Note
- Either instance_name or instance_pattern is required.
Examples
- name: Add tags to instance
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)
gce_tag:
instance_name: test-server
tags: foo,bar
state: absent
- name: Add tags to instances in zone that match pattern
gce_tag:
instance_pattern: test-server-*
tags: foo,bar
zone: us-central1-a
state: present
Status
- This module is not guaranteed to have a backwards compatible interface. [preview]
- This module is maintained by the Ansible Community. [community]
Authors
- Do Hoang Khiem (@dohoangkhiem) <(dohoangkhiem@gmail.com>
- Tom Melendez (@supertom)
Hint
If you notice any issues in this documentation you can edit this document to improve it.
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.8/modules/gce_tag_module.html