- Docs »
- gce_snapshot - Create or destroy snapshots for GCE storage volumes
-
You are reading an unmaintained version of the Ansible documentation. Unmaintained Ansible versions can contain unfixed security vulnerabilities (CVE). Please upgrade to a maintained version. See the latest Ansible documentation.
gce_snapshot - Create or destroy snapshots for GCE storage volumes
- 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
The below requirements are needed on the host that executes this module.
- python >= 2.6
- apache-libcloud >= 0.19.0
Parameter |
Choices/Defaults |
Comments |
credentials_file
required |
|
The path to the credentials file associated with the service account
|
disks
|
Default:
"all"
|
A list of disks to create snapshots for. If none is provided, all of the volumes will be snapshotted
|
instance_name
required |
|
The GCE instance to snapshot
|
project_id
required |
|
The GCP project ID to use
|
service_account_email
required |
|
GCP service account email for the project where the instance resides
|
snapshot_name
|
|
The name of the snapshot to manage
|
state
|
Choices:
present ←
- absent
|
Whether a snapshot should be present or absent
|
- 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
- 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
# 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
Common return values are documented here, the following are the fields unique to this module:
Key |
Returned |
Description |
snapshots_absent
list
|
When snapshots were already absent |
List of snapshots that were already absent (no-op)
Sample:
[disk0-example-snapshot, disk1-example-snapshot]
|
snapshots_created
list
|
When snapshots are created |
List of newly created snapshots
Sample:
[disk0-example-snapshot, disk1-example-snapshot]
|
snapshots_deleted
list
|
When snapshots are deleted |
List of destroyed snapshots
Sample:
[disk0-example-snapshot, disk1-example-snapshot]
|
snapshots_existing
list
|
When snapshots were already present |
List of snapshots that already existed (no-op)
Sample:
[disk0-example-snapshot, disk1-example-snapshot]
|
This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.
This module is flagged as community which means that it is maintained by the Ansible Community. See Module Maintenance & Support for more info.
For a list of other modules that are also maintained by the Ansible Community, see here.
- Rob Wagner (@robwagner33)
Hint
If you notice any issues in this documentation you can edit this document to improve it.