- Docs »
- hetzner.hcloud.hcloud_volume – Create and manage block Volume on the Hetzner Cloud.
-
You are reading the latest community version of the Ansible documentation. Red Hat subscribers, select 2.9 in the version selection to the left for the most recent Red Hat release.
hetzner.hcloud.hcloud_volume – Create and manage block Volume on the Hetzner Cloud.
Note
This plugin is part of the hetzner.hcloud collection (version 1.4.2).
To install it use: ansible-galaxy collection install hetzner.hcloud
.
To use it in a playbook, specify: hetzner.hcloud.hcloud_volume
.
The below requirements are needed on the host that executes this module.
Parameter |
Choices/Defaults |
Comments |
api_token
string
/ required
|
|
This is the API Token for the Hetzner Cloud.
|
automount
boolean
|
|
Automatically mount the Volume.
|
delete_protection
boolean
|
|
Protect the Volume for deletion.
|
endpoint
string
|
Default:
"https://api.hetzner.cloud/v1"
|
This is the API Endpoint for the Hetzner Cloud.
|
format
string
|
|
Automatically Format the volume on creation
Can only be used in case the Volume does not exists.
|
id
integer
|
|
The ID of the Hetzner Cloud Block Volume to manage.
Only required if no volume name is given
|
labels
dictionary
|
|
User-defined key-value pairs.
|
location
string
|
|
Location of the Hetzner Cloud Volume.
Required if no server is given and Volume does not exists.
|
name
string
|
|
The Name of the Hetzner Cloud Block Volume to manage.
Only required if no volume id is given or a volume does not exists.
|
server
string
|
|
Server Name the Volume should be assigned to.
Required if no location is given and Volume does not exists.
|
size
integer
|
|
The size of the Block Volume in GB.
Required if volume does not yet exists.
|
state
string
|
Choices:
- absent
present ←
|
State of the Volume.
|
- name: Create a Volume
hcloud_volume:
name: my-volume
location: fsn1
size: 100
state: present
- name: Create a Volume and format it with ext4
hcloud_volume:
name: my-volume
location: fsn
format: ext4
size: 100
state: present
- name: Mount a existing Volume and automount
hcloud_volume:
name: my-volume
server: my-server
automount: yes
state: present
- name: Mount a existing Volume and automount
hcloud_volume:
name: my-volume
server: my-server
automount: yes
state: present
- name: Ensure the Volume is absent (remove if needed)
hcloud_volume:
name: my-volume
state: absent
Common return values are documented here, the following are the fields unique to this module:
Key |
Returned |
Description |
hcloud_volume
complex
|
Always |
The block Volume
|
|
delete_protection
boolean
added in 0.1.0 of hetzner.hcloud |
always |
True if Volume is protected for deletion
|
|
id
integer
|
Always |
ID of the Volume
Sample:
12345
|
|
labels
dictionary
|
Always |
User-defined labels (key-value pairs)
Sample:
{'key': 'value', 'mylabel': 123}
|
|
linux_device
string
added in 0.1.0 of hetzner.hcloud |
always |
Path to the device that contains the Volume.
Sample:
/dev/disk/by-id/scsi-0HC_Volume_12345
|
|
location
string
|
Always |
Location name where the Volume is located at
Sample:
fsn1
|
|
name
string
|
Always |
Name of the Volume
Sample:
my-volume
|
|
server
string
|
Always |
Server name where the Volume is attached to
Sample:
my-server
|
|
size
integer
|
Always |
Size in GB of the Volume
Sample:
1337
|