hetzner.hcloud.subnetwork module – Manage cloud subnetworks 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.subnetwork.

Synopsis

  • Create, update and delete cloud subnetworks on the Hetzner Cloud.

Aliases: hcloud_subnetwork

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.

ip_range

string / required

IP range of the subnetwork.

network

string / required

The name or ID of the Hetzner Cloud Networks.

network_zone

string / required

Name of network zone.

state

string

State of the subnetwork.

Choices:

  • "absent"

  • "present" ← (default)

type

string / required

Type of subnetwork.

Choices:

  • "server"

  • "cloud"

  • "vswitch"

vswitch_id

integer

ID of the vSwitch you want to couple with your Network.

Required if type == vswitch

See Also

See also

Documentation for Hetzner Cloud API

Complete reference for the Hetzner Cloud API.

Examples

- name: Create a basic subnetwork
  hetzner.hcloud.subnetwork:
    network: my-network
    ip_range: 10.0.0.0/16
    network_zone: eu-central
    type: cloud
    state: present

- name: Create a basic subnetwork
  hetzner.hcloud.subnetwork:
    network: my-vswitch-network
    ip_range: 10.0.0.0/24
    network_zone: eu-central
    type: vswitch
    vswitch_id: 123
    state: present

- name: Ensure the subnetwork is absent (remove if needed)
  hetzner.hcloud.subnetwork:
    network: my-network
    ip_range: 10.0.0.0/8
    network_zone: eu-central
    type: cloud
    state: absent

Return Values

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

Key

Description

hcloud_subnetwork

complex

One Subnet of a Network

Returned: always

gateway

string

Gateway of the subnetwork

Returned: always

Sample: "10.0.0.1"

ip_range

string

IP range of the Network

Returned: always

Sample: "10.0.0.0/8"

network

string

Name of the Network

Returned: always

Sample: "my-network"

network_zone

string

Name of network zone

Returned: always

Sample: "eu-central"

type

string

Type of subnetwork

Returned: always

Sample: "server"

vswitch_id

integer

ID of the vswitch, null if not type vswitch

Returned: always

Sample: 123

Authors

  • Lukas Kaemmerling (@lkaemmerling)