Managing Block Storage
Often, the default disk available on the droplet might not be enough. For such scenarios, DigitalOcean provides a block storage service that can be attached to a droplet as an additional disk. This storage is highly available and easily extendable. Using Ansible, we can create and attach the block storage to a droplet.
How to do it…
- Let's start by creating a 10 GB block. We have to specify the
command
,region
,block_size
, andvolume_name
. The authentication token is also required along with these details. Note that this task will only create the block but will not attach it to any of the droplets:
- digital_ocean_block_storage: state: present command: create region: blr1 block_size: 10 volume_name: cookbook1 api_token: "{{ DO_OAUTH_TOKEN }}"
- Once we have the block, let's attach it to the
app
droplet that we created in the recipe Creating droplets:
- digital_ocean_block_storage: state: present command: attach volume_name: cookbook1 ...