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

Create or destroy snapshots for GCE storage volumes

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

Authors: Rob Wagner (@robwagner33)

preview | supported by community

Install Ansible via pip

Install with pip install ansible==2.9.27

Description

Manages snapshots for GCE instances. This module manages snapshots for the storage volumes of a GCE compute instance. If there are multiple volumes, each snapshot will be prepended with the disk name


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create gce snapshot
  gce_snapshot:
    instance_name: example-instance
    snapshot_name: example-snapshot
    state: present
    service_account_email: project_name@appspot.gserviceaccount.com
    credentials_file: /path/to/credentials
    project_id: project_name
  delegate_to: localhost
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Delete gce snapshot
  gce_snapshot:
    instance_name: example-instance
    snapshot_name: example-snapshot
    state: absent
    service_account_email: project_name@appspot.gserviceaccount.com
    credentials_file: /path/to/credentials
    project_id: project_name
  delegate_to: localhost
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# This example creates snapshots for only two of the available disks as
# disk0-example-snapshot and disk1-example-snapshot
- name: Create snapshots of specific disks
  gce_snapshot:
    instance_name: example-instance
    snapshot_name: example-snapshot
    state: present
    disks:
      - disk0
      - disk1
    service_account_email: project_name@appspot.gserviceaccount.com
    credentials_file: /path/to/credentials
    project_id: project_name
  delegate_to: localhost

Inputs

    
disks:
    default: all
    description:
    - A list of disks to create snapshots for. If none is provided, all of the volumes
      will be snapshotted
    required: false

state:
    choices:
    - present
    - absent
    default: present
    description:
    - Whether a snapshot should be C(present) or C(absent)
    required: false

project_id:
    description:
    - The GCP project ID to use
    required: true

instance_name:
    description:
    - The GCE instance to snapshot
    required: true

snapshot_name:
    description:
    - The name of the snapshot to manage

credentials_file:
    description:
    - The path to the credentials file associated with the service account
    required: true

service_account_email:
    description:
    - GCP service account email for the project where the instance resides
    required: true

Outputs

snapshots_absent:
  description: List of snapshots that were already absent (no-op)
  returned: When snapshots were already absent
  sample: '[disk0-example-snapshot, disk1-example-snapshot]'
  type: list
snapshots_created:
  description: List of newly created snapshots
  returned: When snapshots are created
  sample: '[disk0-example-snapshot, disk1-example-snapshot]'
  type: list
snapshots_deleted:
  description: List of destroyed snapshots
  returned: When snapshots are deleted
  sample: '[disk0-example-snapshot, disk1-example-snapshot]'
  type: list
snapshots_existing:
  description: List of snapshots that already existed (no-op)
  returned: When snapshots were already present
  sample: '[disk0-example-snapshot, disk1-example-snapshot]'
  type: list