ansible.builtin.gce_tag (v2.9.27) — module

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

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

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

preview | supported by community

Install Ansible via pip

Install with pip install ansible==2.9.27

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.
- name: Add tags to instance
  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.
- name: Remove tags from instance 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.
- 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

Inputs

    
tags:
    description:
    - Comma-separated list of tags to add or remove.
    required: true

zone:
    default: us-central1-a
    description:
    - The zone of the disk specified by source.

state:
    choices:
    - absent
    - present
    default: present
    description:
    - Desired state of the tags.

pem_file:
    description:
    - Path to the PEM file associated with the service account email.

project_id:
    description:
    - Your GCE project ID.

instance_name:
    description:
    - The name of the GCE instance to add/remove tags.
    - Required if C(instance_pattern) is not specified.

instance_pattern:
    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 C(instance_name) is not specified, this field is required.
    version_added: '2.3'
    version_added_collection: ansible.builtin

service_account_email:
    description:
    - Service account email.