hetzner.hcloud.volume module – Create and manage block Volume on the Hetzner Cloud.
Note
This module is part of the hetzner.hcloud collection (version 4.2.2).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install hetzner.hcloud
.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: hetzner.hcloud.volume
.
Synopsis
Create, update and attach/detach block Volume on the Hetzner Cloud.
Aliases: hcloud_volume
Requirements
The below requirements are needed on the host that executes this module.
python-dateutil >= 2.7.5
requests >=2.20
Parameters
Parameter |
Comments |
---|---|
The API Endpoint for the Hetzner Cloud. You can also set this option by using the Default: |
|
The API Token for the Hetzner Cloud. You can also set this option by using the |
|
Automatically mount the Volume. Choices:
|
|
Protect the Volume for deletion. Choices:
|
|
Automatically Format the volume on creation Can only be used in case the Volume does not exist. Choices:
|
|
The ID of the Hetzner Cloud Block Volume to manage. Only required if no volume name is given |
|
User-defined key-value pairs. |
|
Location of the Hetzner Cloud Volume. Required if no server is given and Volume does not exist. |
|
The Name of the Hetzner Cloud Block Volume to manage. Only required if no volume id is given or a volume does not exist. |
|
Server Name the Volume should be assigned to. Required if no location is given and Volume does not exist. |
|
The size of the Block Volume in GB. Required if volume does not yet exists. |
|
State of the Volume. Choices:
|
See Also
See also
- Documentation for Hetzner Cloud API
Complete reference for the Hetzner Cloud API.
Examples
- name: Create a Volume
hetzner.hcloud.volume:
name: my-volume
location: fsn1
size: 100
state: present
- name: Create a Volume and format it with ext4
hetzner.hcloud.volume:
name: my-volume
location: fsn
format: ext4
size: 100
state: present
- name: Mount a existing Volume and automount
hetzner.hcloud.volume:
name: my-volume
server: my-server
automount: true
state: present
- name: Mount a existing Volume and automount
hetzner.hcloud.volume:
name: my-volume
server: my-server
automount: true
state: present
- name: Ensure the Volume is absent (remove if needed)
hetzner.hcloud.volume:
name: my-volume
state: absent
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
The block Volume Returned: Always |
|
True if Volume is protected for deletion Returned: always Sample: |
|
ID of the Volume Returned: Always Sample: |
|
User-defined labels (key-value pairs) Returned: Always Sample: |
|
Path to the device that contains the Volume. Returned: always Sample: |
|
Location name where the Volume is located at Returned: Always Sample: |
|
Name of the Volume Returned: Always Sample: |
|
Server name where the Volume is attached to Returned: Always Sample: |
|
Size in GB of the Volume Returned: Always Sample: |