ansible.builtin.digital_ocean_block_storage (v2.5.11) — module

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

| "added in version" 2.2 of ansible.builtin"

Authors: Harnek Sidhu (github: @harneksidhu)

preview | supported by community

Install Ansible via pip

Install with pip install ansible==2.5.11

Description

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

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Delete Block Storage
- digital_ocean_block_storage:
    state: absent
    command: create
    api_token: <TOKEN>
    region: nyc1
    volume_name: nyc1-block-storage
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# 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>
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# 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>

Inputs

    
state:
    choices:
    - present
    - absent
    description:
    - Indicate desired state of the target.
    required: true

region:
    description:
    - The slug of the region where your Block Storage volume should be located in. If
      snapshot_id is included, this will be ignored.
    required: true

command:
    choices:
    - create
    - attach
    description:
    - Which operation do you want to perform.
    required: true

timeout:
    default: 10
    description:
    - The timeout in seconds used for polling DigitalOcean's API.

api_token:
    description:
    - DigitalOcean api token.
    required: true

block_size:
    description:
    - 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.

droplet_id:
    description:
    - The droplet id you want to operate on. Required when command=attach.

description:
    description:
    - Description of the Block Storage volume.

snapshot_id:
    description:
    - 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.
    version_added: '2.5'
    version_added_collection: ansible.builtin

volume_name:
    description:
    - The name of the Block Storage volume.
    required: true

Outputs

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