hetzner.hcloud.volume_attachment module – Manage the attachment of Hetzner Cloud Volumes
Note
This module is part of the hetzner.hcloud collection (version 6.9.0).
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_attachment.
Synopsis
- Attach and detach Volumes from Hetzner Cloud Servers.
Aliases: hcloud_volume_attachment
Requirements
The below requirements are needed on the host that executes this module.
- python-dateutil >= 2.7.5
- requests >=2.20
Parameters
Parameter | Comments |
|---|---|
api_endpoint aliases: endpoint string | The endpoint for the Hetzner Cloud API. You can also set this option by using the Default: |
api_endpoint_hetzner string | The endpoint for the Hetzner API. You can also set this option by using the Default: |
api_token string / required | The token for the Hetzner Cloud API. You can also set this option by using the |
automount boolean | Automatically mount the Volume in the Server. Choices:
|
server string | Name or ID of the Hetzner Cloud Server to attach the Volume to. Required if |
state string | State of the Volume. Choices:
|
volume string / required | Name or ID of the Hetzner Cloud Volume to attach/detach. |
See Also
See also
- Documentation for Hetzner APIs
-
Complete reference for the Hetzner APIs.
Examples
- name: Attach my-volume to my-server
hetzner.hcloud.volume_attachment:
volume: my-volume
server: my-server
- name: Detach my-volume from my-server
hetzner.hcloud.volume_attachment:
volume: my-volume
state: absent
- name: Attach my-volume using id to my-server with automount enabled
hetzner.hcloud.volume_attachment:
volume: 123456
server: my-server
automount: true
state: present
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key | Description |
|---|---|
hcloud_volume_attachment dictionary | The relationship between a Server and a Volume Returned: always |
|
server string |
Name of the attached Server Returned: always Sample: |
|
volume string |
Name of the Volume Returned: always Sample: |
Collection links
© 2012–2018 Michael DeHaan
© 2018–2025 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/projects/ansible/latest/collections/hetzner/hcloud/volume_attachment_module.html