community.general.gce_tag (1.3.14) — module

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

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

Install collection

Install with ansible-galaxy collection install community.general:==1.3.14


Add to requirements.yml

  collections:
    - name: community.general
      version: 1.3.14

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
  community.general.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)
  community.general.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
  community.general.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
    type: list

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

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

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

project_id:
    description:
    - Your GCE project ID.
    type: str

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

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.
    type: str

service_account_email:
    description:
    - Service account email.
    type: str