hetzner.hcloud.volume_attachment module – Manage the attachment of Hetzner Cloud Volumes

Note

This module is part of the hetzner.hcloud collection (version 5.2.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 API Endpoint for the Hetzner Cloud.

You can also set this option by using the HCLOUD_ENDPOINT environment variable.

Default: "https://api.hetzner.cloud/v1"

api_token

string / required

The API Token for the Hetzner Cloud.

You can also set this option by using the HCLOUD_TOKEN environment variable.

automount

boolean

Automatically mount the Volume in the Server.

Choices:

  • false

  • true

server

string

Name or ID of the Hetzner Cloud Server to attach the Volume to.

Required if state=present.

state

string

State of the Volume.

Choices:

  • "present" ← (default)

  • "absent"

volume

string / required

Name or ID of the Hetzner Cloud Volume to attach/detach.

See Also

See also

Documentation for Hetzner Cloud API

Complete reference for the Hetzner Cloud API.

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

complex

The relationship between a Server and a Volume

Returned: always

server

string

Name of the attached Server

Returned: always

Sample: "my-server"

volume

string

Name of the Volume

Returned: always

Sample: "my-volume"

Authors

  • Amirhossein Shaerpour (@shaerpour)