community / community.digitalocean / 1.26.0 / module / digital_ocean_block_storage Create/destroy or attach/detach Block Storage volumes in DigitalOcean Authors: Harnek Sidhu (@harneksidhu)community.digitalocean.digital_ocean_block_storage (1.26.0) — module
Install with ansible-galaxy collection install community.digitalocean:==1.26.0
collections: - name: community.digitalocean version: 1.26.0
Create/destroy Block Storage volume in DigitalOcean, or attach/detach Block Storage volume to a droplet.
- name: Create new Block Storage community.digitalocean.digital_ocean_block_storage: state: present oauth_token: "{{ lookup('ansible.builtin.env', 'DO_API_TOKEN') }}" command: create region: nyc1 block_size: 10 volume_name: nyc1-block-storage
- name: Create new Block Storage (and assign to Project "test") community.digitalocean.digital_ocean_block_storage: state: present oauth_token: "{{ lookup('ansible.builtin.env', 'DO_API_TOKEN') }}" command: create region: nyc1 block_size: 10 volume_name: nyc1-block-storage project_name: test
- name: Resize an existing Block Storage community.digitalocean.digital_ocean_block_storage: state: present oauth_token: "{{ lookup('ansible.builtin.env', 'DO_API_TOKEN') }}" command: create region: nyc1 block_size: 20 volume_name: nyc1-block-storage
- name: Delete Block Storage community.digitalocean.digital_ocean_block_storage: state: absent oauth_token: "{{ lookup('ansible.builtin.env', 'DO_API_TOKEN') }}" command: create region: nyc1 volume_name: nyc1-block-storage
- name: Attach Block Storage to a Droplet community.digitalocean.digital_ocean_block_storage: state: present oauth_token: "{{ lookup('ansible.builtin.env', 'DO_API_TOKEN') }}" command: attach volume_name: nyc1-block-storage region: nyc1 droplet_id: <ID>
- name: Detach Block Storage from a Droplet community.digitalocean.digital_ocean_block_storage: state: absent oauth_token: "{{ lookup('ansible.builtin.env', 'DO_API_TOKEN') }}" command: attach volume_name: nyc1-block-storage region: nyc1 droplet_id: <ID>
state: choices: - present - absent description: - Indicate desired state of the target. required: true type: str region: description: - The slug of the region where your Block Storage volume should be located in. - If I(snapshot_id) is included, this will be ignored. type: str baseurl: default: https://api.digitalocean.com/v2 description: - DigitalOcean API base url. type: str command: choices: - create - attach description: - Which operation do you want to perform. required: true type: str timeout: default: 30 description: - The timeout in seconds used for polling DigitalOcean's API. type: int block_size: description: - The size of the Block Storage volume in gigabytes. - Required when I(command=create) and I(state=present). - If snapshot_id is included, this will be ignored. - If block_size > current size of the volume, the volume is resized. type: int droplet_id: description: - The droplet id you want to operate on. - Required when I(command=attach). type: int description: description: - Description of the Block Storage volume. type: str oauth_token: aliases: - api_token description: - DigitalOcean OAuth token. - There are several other environment variables which can be used to provide this value. - i.e., - C(DO_API_TOKEN), C(DO_API_KEY), C(DO_OAUTH_TOKEN) and C(OAUTH_TOKEN). type: str snapshot_id: description: - The snapshot id you would like the Block Storage volume created with. - If included, I(region) and I(block_size) will be ignored and changed to C(null). type: str volume_name: description: - The name of the Block Storage volume. required: true type: str project_name: aliases: - project default: '' description: - Project to assign the resource to (project name, not UUID). - Defaults to the default project of the account (empty string). - Currently only supported when C(command=create). required: false type: str validate_certs: default: true description: - If set to C(no), the SSL certificates will not be validated. - This should only set to C(no) used on personally controlled sites using self-signed certificates. type: bool
assign_status: description: Assignment status (ok, not_found, assigned, already_assigned, service_down) returned: changed sample: assigned type: str id: description: Unique identifier of a Block Storage volume returned during creation. returned: changed sample: 69b25d9a-494c-12e6-a5af-001f53126b44 type: str msg: description: Informational or error message encountered during execution returned: changed sample: No project named test2 found type: str resources: description: Resource assignment involved in project assignment returned: changed sample: assigned_at: '2021-10-25T17:39:38Z' links: self: https://api.digitalocean.com/v2/volumes/8691c49e-35ba-11ec-9406-0a58ac1472b9 status: assigned urn: do:volume:8691c49e-35ba-11ec-9406-0a58ac1472b9 type: dict