hetzner.hcloud.server_network module – Manage the relationship between Hetzner Cloud Networks and servers

Note

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

Synopsis

  • Create and delete the relationship Hetzner Cloud Networks and servers

Aliases: hcloud_server_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

alias_ips

list / elements=string

Alias IPs the server has.

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

string

The IP the server should have.

network

string / required

Name or ID of the Hetzner Cloud Networks.

server

string / required

Name or ID of the Hetzner Cloud server.

state

string

State of the server_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 server network
  hetzner.hcloud.server_network:
    network: my-network
    server: my-server
    state: present

- name: Create a server network and specify the ip address
  hetzner.hcloud.server_network:
    network: my-network
    server: my-server
    ip: 10.0.0.1
    state: present

- name: Create a server network and add alias ips
  hetzner.hcloud.server_network:
    network: my-network
    server: my-server
    ip: 10.0.0.1
    alias_ips:
      - 10.1.0.1
      - 10.2.0.1
    state: present

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

Return Values

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

Key

Description

hcloud_server_network

complex

The relationship between a server and a network

Returned: always

alias_ips

list / elements=string

Alias IPs of the server within the Network ip range

Returned: always

Sample: ["10.1.0.1", "..."]

ip

string

IP of the server within the Network ip range

Returned: always

Sample: "10.0.0.8"

network

string

Name of the Network

Returned: always

Sample: "my-network"

server

string

Name of the server

Returned: always

Sample: "my-server"

Authors

  • Lukas Kaemmerling (@lkaemmerling)