hetzner.hcloud.storage_box module – Create and manage Storage Boxes in Hetzner.

Note

This module is part of the hetzner.hcloud collection (version 6.4.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.storage_box.

Synopsis

Aliases: hcloud_storage_box

Requirements

The below requirements are needed on the host that executes this module.

  • python-dateutil >= 2.7.5

  • requests >=2.20

Parameters

Parameter

Comments

access_settings

dictionary

Access settings of the Storage Box.

reachable_externally

boolean

Whether access from outside the Hetzner network is allowed.

Choices:

  • false ← (default)

  • true

samba_enabled

boolean

Whether the Samba subsystem is enabled.

Choices:

  • false ← (default)

  • true

ssh_enabled

boolean

Whether the SSH subsystem is enabled.

Choices:

  • false ← (default)

  • true

webdav_enabled

boolean

Whether the WebDAV subsystem is enabled.

Choices:

  • false ← (default)

  • true

zfs_enabled

boolean

Whether the ZFS snapshot folder is visible.

Choices:

  • false ← (default)

  • true

api_endpoint

aliases: endpoint

string

The endpoint for the Hetzner Cloud API.

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

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

api_endpoint_hetzner

string

The endpoint for the Hetzner API.

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

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

api_token

string / required

The token for the Hetzner Cloud API.

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

delete_protection

boolean

Protect the Storage Box from deletion.

Choices:

  • false

  • true

id

integer

ID of the Storage Box to manage.

Required if no Storage Box name is given.

If the ID is invalid, the module will fail.

labels

dictionary

User-defined labels (key-value pairs) for the Storage Box.

location

string

Name or ID of the Location for the Storage Box.

Required if the Storage Box does not exist.

name

string

Name of the Storage Box to manage.

Required if no Storage Box id is given.

Required if the Storage Box does not exist.

password

string

Password for the Storage Box.

Required if the Storage Box does not exist.

snapshot

string

Snapshot ID or Name to rollback to.

Only used when state=rollback_snapshot

snapshot_plan

dictionary

Snapshot plan of the Storage Box.

Use null to disabled the snapshot plan.

day_of_month

integer

Day of the month when the Snapshot Plan is executed.

Null means every day.

day_of_week

integer

Day of the week when the Snapshot Plan is executed.

Starts at 1 for Monday til 7 for Sunday.

Null means every day.

hour

integer / required

Hour when the Snapshot Plan is executed (UTC).

max_snapshots

integer / required

Maximum amount of Snapshots that will be created by this Snapshot Plan.

Older Snapshots will be deleted.

minute

integer / required

Minute when the Snapshot Plan is executed (UTC).

ssh_keys

list / elements=string

SSH public keys in OpenSSH format to inject into the Storage Box.

state

string

State of the Storage Box.

reset_password and rollback_snapshot are not idempotent.

Choices:

  • "absent"

  • "present" ← (default)

  • "reset_password"

  • "rollback_snapshot"

storage_box_type

aliases: type

string

Name or ID of the Storage Box Type for the Storage Box.

Required if the Storage Box does not exist.

See Also

See also

Documentation for Hetzner APIs

Complete reference for the Hetzner APIs.

Examples

- name: Create a Storage Box
  hetzner.hcloud.storage_box:
    name: my-storage-box
    storage_box_type: bx11
    location: fsn1
    password: my-secret
    labels:
      env: prod
    state: present

- name: Create a Storage Box with access settings
  hetzner.hcloud.storage_box:
    name: my-storage-box
    storage_box_type: bx11
    location: fsn1
    password: my-secret
    access_settings:
      reachable_externally: true
      ssh_enabled: true
      samba_enabled: false
      webdav_enabled: false
      zfs_enabled: false
    state: present

- name: Create a Storage Box with snapshot plan
  hetzner.hcloud.storage_box:
    name: my-storage-box
    storage_box_type: bx11
    location: fsn1
    password: my-secret
    snapshot_plan:
      max_snapshots: 10
      hour: 3
      minute: 30
    state: present

- name: Disable a Storage Box snapshot plan
  hetzner.hcloud.storage_box:
    name: my-storage-box
    snapshot_plan: null
    state: present

- name: Reset a Storage Box password
  hetzner.hcloud.storage_box:
    name: my-storage-box
    password: my-secret
    state: reset_password

- name: Rollback a Storage Box to a Snapshot
  hetzner.hcloud.storage_box:
    name: my-storage-box
    snapshot: 2025-12-03T13-47-47
    state: rollback_snapshot

- name: Delete a Storage Box
  hetzner.hcloud.storage_box:
    name: my-storage-box
    state: absent

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

hcloud_storage_box

dictionary

Details about the Storage Box.

Returned: always

access_settings

dictionary

Access settings of the Storage Box.

Returned: always

reachable_externally

boolean

Whether access from outside the Hetzner network is allowed.

Returned: always

Sample: false

samba_enabled

boolean

Whether the Samba subsystem is enabled.

Returned: always

Sample: false

ssh_enabled

boolean

Whether the SSH subsystem is enabled.

Returned: always

Sample: true

webdav_enabled

boolean

Whether the WebDAV subsystem is enabled.

Returned: always

Sample: false

zfs_enabled

boolean

Whether the ZFS snapshot folder is visible.

Returned: always

Sample: false

delete_protection

boolean

Protect the Storage Box from deletion.

Returned: always

Sample: false

id

integer

ID of the Storage Box.

Returned: always

Sample: 1937415

labels

dictionary

User-defined labels (key-value pairs) of the Storage Box.

Returned: always

Sample: {"env": "prod"}

location

string

Name of the Location of the Storage Box.

Returned: always

Sample: "fsn1"

name

string

Name of the Storage Box.

Returned: always

Sample: "my-storage-box"

server

string

FQDN of the Storage Box.

Returned: always

Sample: "u505337.your-storagebox.de"

snapshot_plan

dictionary

Snapshot plan of the Storage Box.

Returned: when enabled

day_of_month

integer

Day of the month when the Snapshot Plan is executed. Null means every day.

Returned: always

Sample: 30

day_of_week

integer

Day of the week when the Snapshot Plan is executed. Null means every day.

Returned: always

Sample: 1

hour

integer

Hour when the Snapshot Plan is executed (UTC).

Returned: always

Sample: 3

max_snapshots

integer

Maximum amount of Snapshots that will be created by this Snapshot Plan.

Returned: always

Sample: 10

minute

integer

Minute when the Snapshot Plan is executed (UTC).

Returned: always

Sample: 30

stats

dictionary

Statistics of the Storage Box.

Returned: always

size

integer

Current disk usage in bytes.

Returned: always

Sample: 10485760

size_data

integer

Current disk usage for data in bytes.

Returned: always

Sample: 10485760

size_snapshots

integer

Current disk usage for snapshots in bytes.

Returned: always

Sample: 10485760

status

string

Status of the Storage Box.

Returned: always

Sample: "active"

storage_box_type

string

Name of the Storage Box Type.

Returned: always

Sample: "bx11"

system

string

Host system of the Storage Box.

Returned: always

Sample: "HEL1-BX136"

username

string

User name of the Storage Box.

Returned: always

Sample: "u505337"

Authors

  • Jonas Lammler (@jooola)