community.digitalocean.digital_ocean_snapshot – Create and delete DigitalOcean snapshots

Note

This plugin is part of the community.digitalocean collection (version 1.9.0).

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

Synopsis

  • This module can be used to create and delete DigitalOcean Droplet and volume snapshots.

Parameters

Parameter Choices/Defaults Comments
droplet_id
string
Droplet ID to snapshot.
oauth_token
string
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'

aliases: api_token
snapshot_id
string
Snapshot ID to delete.
snapshot_name
string
Name of the snapshot to create.
snapshot_tags
list / elements=string
List of tags to apply to the volume snapshot.
Only applies to volume snapshots (not Droplets).
snapshot_type
string
    Choices:
  • droplet ←
  • volume
Specifies the type of snapshot information to be create or delete.
If set to droplet, then a Droplet snapshot is created.
If set to volume, then a volume snapshot is created.
state
string
    Choices:
  • present ←
  • absent
Whether the snapshot should be present (created) or absent (deleted).
timeout
integer
Default:
30
The timeout in seconds used for polling DigitalOcean's API.
validate_certs
boolean
    Choices:
  • no
  • yes ←
If set to no, the SSL certificates will not be validated.
This should only set to no used on personally controlled sites using self-signed certificates.
volume_id
string
Volume ID to snapshot.
wait
boolean
    Choices:
  • no
  • yes ←
Wait for the snapshot to be created before returning.
wait_timeout
integer
Default:
120
How long before wait gives up, in seconds, when creating a snapshot.

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 Returned Description
data
dictionary
success
Snapshot creation or deletion action.

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', '<snip>'], '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)