hetzner.hcloud.network module – Create and manage cloud Networks on the Hetzner Cloud.

Note

This module is part of the hetzner.hcloud collection (version 3.1.1).

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.network.

Synopsis

  • Create, update and manage cloud Networks on the Hetzner Cloud.

  • You need at least hcloud-python 1.3.0.

Aliases: hcloud_network

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.

delete_protection

boolean

Protect the Network for deletion.

Choices:

  • false

  • true

expose_routes_to_vswitch

boolean

Indicates if the routes from this network should be exposed to the vSwitch connection.

The exposing only takes effect if a vSwitch connection is active.

Choices:

  • false

  • true

id

integer

The ID of the Hetzner Cloud Networks to manage.

Only required if no Network name is given.

ip_range

string

IP range of the Network.

Required if Network does not exist.

labels

dictionary

User-defined labels (key-value pairs).

name

string

The Name of the Hetzner Cloud Network to manage.

Only required if no Network id is given or a Network does not exist.

state

string

State of the Network.

Choices:

  • "absent"

  • "present" ← (default)

See Also

See also

Documentation for Hetzner Cloud API

Complete reference for the Hetzner Cloud API.

Examples

- name: Create a basic network
  hetzner.hcloud.network:
    name: my-network
    ip_range: 10.0.0.0/8
    state: present

- name: Ensure the Network is absent (remove if needed)
  hetzner.hcloud.network:
    name: my-network
    state: absent

Return Values

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

Key

Description

hcloud_network

complex

The Network

Returned: always

delete_protection

boolean

added in hetzner.hcloud 0.1.0

True if Network is protected for deletion

Returned: always

Sample: false

expose_routes_to_vswitch

boolean

Indicates if the routes from this network should be exposed to the vSwitch connection.

Returned: always

Sample: false

id

integer

ID of the Network

Returned: always

Sample: 12345

ip_range

string

IP range of the Network

Returned: always

Sample: "10.0.0.0/8"

labels

dictionary

User-defined labels (key-value pairs)

Returned: always

Sample: {"key": "value", "mylabel": 123}

name

string

Name of the Network

Returned: always

Sample: "my-volume"

Authors

  • Lukas Kaemmerling (@lkaemmerling)