community.digitalocean.digital_ocean_snapshot module – Create and delete DigitalOcean snapshots
Note
This module is part of the community.digitalocean collection (version 1.24.0).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install community.digitalocean
.
To use it in a playbook, specify: community.digitalocean.digital_ocean_snapshot
.
New in community.digitalocean 1.7.0
Synopsis
This module can be used to create and delete DigitalOcean Droplet and volume snapshots.
Parameters
Parameter |
Comments |
---|---|
DigitalOcean API base url. Default: |
|
Droplet ID to snapshot. |
|
DigitalOcean OAuth token. There are several other environment variables which can be used to provide this value. i.e., - ‘DO_API_TOKEN’, ‘DO_API_KEY’, ‘DO_OAUTH_TOKEN’ and ‘OAUTH_TOKEN’ |
|
Snapshot ID to delete. |
|
Name of the snapshot to create. |
|
List of tags to apply to the volume snapshot. Only applies to volume snapshots (not Droplets). |
|
Specifies the type of snapshot information to be create or delete. If set to If set to Choices:
|
|
Whether the snapshot should be present (created) or absent (deleted). Choices:
|
|
The timeout in seconds used for polling DigitalOcean’s API. Default: |
|
If set to This should only set to Choices:
|
|
Volume ID to snapshot. |
|
Wait for the snapshot to be created before returning. Choices:
|
|
How long before wait gives up, in seconds, when creating a snapshot. Default: |
Examples
- name: Snapshot a Droplet
community.digitalocean.digital_ocean_snapshot:
state: present
snapshot_type: droplet
droplet_id: 250329179
register: result
- name: Delete a Droplet snapshot
community.digitalocean.digital_ocean_snapshot:
state: absent
snapshot_type: droplet
snapshot_id: 85905825
register: result
- name: Snapshot a Volume
community.digitalocean.digital_ocean_snapshot:
state: present
snapshot_type: volume
snapshot_name: mysnapshot1
volume_id: 9db5e329-cc68-11eb-b027-0a58ac144f91
- name: Delete a Volume snapshot
community.digitalocean.digital_ocean_snapshot:
state: absent
snapshot_type: volume
snapshot_id: a902cdba-cc68-11eb-a701-0a58ac145708
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
Snapshot creation or deletion action. Returned: success Sample: |