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

New in version 2.2.

Synopsis

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

Options

parameter required default choices comments
api_token
yes
DigitalOcean api token.
block_size
no
The size of the Block Storage volume in gigabytes. Required when command=create and state=present.
command
yes
  • create
  • attach
Which operation do you want to perform.
description
no
Description of the Block Storage volume.
droplet_id
no
The droplet id you want to operate on. Required when command=attach.
region
yes
The slug of the region where your Block Storage volume should be located in.
state
yes
  • present
  • absent
Indicate desired state of the target.
timeout
no 10
The timeout in seconds used for polling DigitalOcean's API.
volume_name
yes
The name of the Block Storage volume.

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 Return Values, the following are the fields unique to this module:

name description returned type sample
id
Unique identifier of a Block Storage volume returned during creation.
changed string 69b25d9a-494c-12e6-a5af-001f53126b44

Notes

Note

  • Two environment variables can be used, DO_API_KEY and DO_API_TOKEN. They both refer to the v2 token.

Status

This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.

For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Testing Ansible and Developing Modules.

© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.4/digital_ocean_block_storage_module.html