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

Note

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

To use it in a playbook, specify: hetzner.hcloud.hcloud_load_balancer_target.

New in version 0.1.0: of hetzner.hcloud

Synopsis

  • Create and delete Hetzner Cloud Load Balancer targets

Requirements

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

  • hcloud-python >= 1.0.0

  • hcloud-python >= 1.8.1

Parameters

Parameter

Comments

api_token

string / required

This is the API Token for the Hetzner Cloud.

endpoint

string

This is the API Endpoint for the Hetzner Cloud.

Default: “https://api.hetzner.cloud/v1”

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

The name of the Hetzner Cloud Load Balancer.

server

string

The name 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.hcloud.hcloud_load_balancer_network

Choices:

  • no ← (default)

  • yes

See Also

See also

Documentation for Hetzner Cloud API

Complete reference for the Hetzner Cloud API.

Examples

- name: Create a server Load Balancer target
  hcloud_load_balancer_target:
    type: server
    load_balancer: my-LoadBalancer
    server: my-server
    state: present

- name: Create a label_selector Load Balancer target
  hcloud_load_balancer_target:
    type: server
    load_balancer: my-LoadBalancer
    label_selector: application=backend
    state: present

- name: Create an IP Load Balancer target
  hcloud_load_balancer_target:
    type: server
    load_balancer: my-LoadBalancer
    ip: 127.0.0.1
    state: present

- name: Ensure the Load Balancer target is absent (remove if needed)
  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.hcloud.hcloud_load_balancer_network

Returned: always

Sample: true

Authors

  • Lukas Kaemmerling (@lkaemmerling)