digital_ocean_block_storage – Create/destroy or attach/detach Block Storage volumes in DigitalOcean

Synopsis

  • Create/destroy Block Storage volume in DigitalOcean, or attach/detach Block Storage volume to a droplet.

Parameters

Parameter Choices/Defaults Comments
block_size
-
The size of the Block Storage volume in gigabytes. Required when command=create and state=present. If snapshot_id is included, this will be ignored.
command
- / required
    Choices:
  • create
  • attach
Which operation do you want to perform.
description
-
Description of the Block Storage volume.
droplet_id
-
The droplet id you want to operate on. Required when command=attach.
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
region
- / required
The slug of the region where your Block Storage volume should be located in. If snapshot_id is included, this will be ignored.
snapshot_id
-
added in 2.5
The snapshot id you would like the Block Storage volume created with. If included, region and block_size will be ignored and changed to null.
state
- / required
    Choices:
  • present
  • absent
Indicate desired state of the target.
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_name
- / required
The name of the Block Storage volume.

Notes

Note

  • Two environment variables can be used, DO_API_KEY and DO_API_TOKEN. They both refer to the v2 token.
  • If snapshot_id is used, region and block_size will be ignored and changed to null.

Examples

# Create new Block Storage
- digital_ocean_block_storage:
    state: present
    command: create
    api_token: <TOKEN>
    region: nyc1
    block_size: 10
    volume_name: nyc1-block-storage
# Delete Block Storage
- digital_ocean_block_storage:
    state: absent
    command: create
    api_token: <TOKEN>
    region: nyc1
    volume_name: nyc1-block-storage
# Attach Block Storage to a Droplet
- digital_ocean_block_storage:
    state: present
    command: attach
    api_token: <TOKEN>
    volume_name: nyc1-block-storage
    region: nyc1
    droplet_id: <ID>
# Detach Block Storage from a Droplet
- digital_ocean_block_storage:
    state: absent
    command: attach
    api_token: <TOKEN>
    volume_name: nyc1-block-storage
    region: nyc1
    droplet_id: <ID>

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key Returned Description
id
string
changed
Unique identifier of a Block Storage volume returned during creation.

Sample:
69b25d9a-494c-12e6-a5af-001f53126b44


Status

Authors

  • Harnek Sidhu (@harneksidhu)

Hint

If you notice any issues in this documentation, you can edit this document to improve it.