community.digitalocean.digital_ocean_snapshot module – Create and delete DigitalOcean snapshots
Note
This module is part of the community.digitalocean collection (version 1.20.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 version 1.7.0: of community.digitalocean
Parameters
Parameter |
Comments |
---|---|
DigitalOcean API base url. Default: “https://api.digitalocean.com/v2” |
|
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: 30 |
|
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: 120 |
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: [{“completed_at”: “2021-06-14T12:36:00Z”, “id”: 1229119156, “region”: {“available”: true, “features”: [“backups”, “ipv6”, “metadata”, “install_agent”, “storage”, “image_transfer”], “name”: “New York 1”, “sizes”: [“s-1vcpu-1gb”, “s-1vcpu-1gb-amd”, “s-1vcpu-1gb-intel”, “\u003csnip\u003e”], “slug”: “nyc1”}, “region_slug”: “nyc1”, “resource_id”: 250445117, “resource_type”: “droplet”, “started_at”: “2021-06-14T12:35:25Z”, “status”: “completed”, “type”: “snapshot”}, {“created_at”: “2021-06-14T12:55:10Z”, “id”: “c06d4a86-cd0f-11eb-b13c-0a58ac145472”, “min_disk_size”: 1, “name”: “my-snapshot-1”, “regions”: [“nbg1”], “resource_id”: “f0adea7e-cd0d-11eb-b027-0a58ac144f91”, “resource_type”: “volume”, “size_gigabytes”: 0, “tags”: [“tag1”, “tag2”]}] |
Authors
Mark Mercado (@mamercad)