hetzner.hcloud.load_balancer_target module – Manage Hetzner Cloud Load Balancer targets

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

New in hetzner.hcloud 0.1.0

Synopsis

  • Create and delete Hetzner Cloud Load Balancer targets

Aliases: hcloud_load_balancer_target

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

string

An IP from a Hetzner Dedicated Server, needs to belongs to the same user as the project.

Required if type is ip

label_selector

string

A Label Selector that will be used to determine the targets dynamically

Required if type is label_selector

load_balancer

string / required

Name or ID of the Hetzner Cloud Load Balancer.

server

string

Name or ID of the Hetzner Cloud Server.

Required if type is server

state

string

State of the load_balancer_network.

Choices:

  • "absent"

  • "present" ← (default)

type

string / required

The type of the target.

Choices:

  • "server"

  • "label_selector"

  • "ip"

use_private_ip

boolean

Route the traffic over the private IP of the Load Balancer through a Hetzner Cloud Network.

Load Balancer needs to be attached to a network. See hetzner.hcloud.load_balancer_network

Choices:

  • false ← (default)

  • true

See Also

See also

Documentation for Hetzner Cloud API

Complete reference for the Hetzner Cloud API.

Examples

- name: Create a server Load Balancer target
  hetzner.hcloud.load_balancer_target:
    type: server
    load_balancer: my-LoadBalancer
    server: my-server
    state: present

- name: Create a label_selector Load Balancer target
  hetzner.hcloud.load_balancer_target:
    type: label_selector
    load_balancer: my-LoadBalancer
    label_selector: application=backend
    state: present

- name: Create an IP Load Balancer target
  hetzner.hcloud.load_balancer_target:
    type: ip
    load_balancer: my-LoadBalancer
    ip: 127.0.0.1
    state: present

- name: Ensure the Load Balancer target is absent (remove if needed)
  hetzner.hcloud.load_balancer_target:
    type: server
    load_balancer: my-LoadBalancer
    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_load_balancer_target

complex

The relationship between a Load Balancer and a network

Returned: always

ip

string

IP of the dedicated server

Returned: if type is ip

Sample: "127.0.0.1"

label_selector

string

Label Selector

Returned: if type is label_selector

Sample: "application=backend"

load_balancer

string

Name of the Load Balancer

Returned: always

Sample: "my-LoadBalancer"

server

string

Name of the Server

Returned: if type is server

Sample: "my-server"

type

string

Type of the Load Balancer Target

Returned: always

Sample: "server"

use_private_ip

boolean

Route the traffic over the private IP of the Load Balancer through a Hetzner Cloud Network.

Load Balancer needs to be attached to a network. See hetzner.hcloud.load_balancer_network

Returned: always

Sample: true

Authors

  • Lukas Kaemmerling (@lkaemmerling)