ansible.builtin.gce_tag (v2.3.2.0-1) — module

add or remove tag(s) to/from GCE instances

| "added in version" 2.0 of ansible.builtin"

Authors: Do Hoang Khiem (dohoangkhiem@gmail.com), Tom Melendez (@supertom)

preview | supported by community

Install Ansible via pip

Install with pip install ansible==2.3.2.0.post1

Description

This module can add or remove tags U(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

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# 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

Inputs

    
tags:
    aliases: []
    default: null
    description:
    - comma-separated list of tags to add or remove
    required: true

zone:
    aliases: []
    default: us-central1-a
    description:
    - the zone of the disk specified by source
    required: false

state:
    aliases: []
    choices:
    - present
    - absent
    default: present
    description:
    - desired state of the tags
    required: false

pem_file:
    aliases: []
    default: null
    description:
    - path to the pem file associated with the service account email
    required: false

project_id:
    aliases: []
    default: null
    description:
    - your GCE project ID
    required: false

instance_name:
    aliases: []
    default: null
    description:
    - The name of the GCE instance to add/remove tags.  Required if instance_pattern is
      not specified.
    required: false

instance_pattern:
    aliases: []
    default: null
    description:
    - The pattern of GCE instance names to match for adding/removing tags.  Full-Python
      regex is supported. See U(https://docs.python.org/2/library/re.html) for details.
      If instance_name is not specified, this field is required.
    required: false
    version_added: '2.3'
    version_added_collection: ansible.builtin

service_account_email:
    aliases: []
    default: null
    description:
    - service account email
    required: false