hetzner.hcloud.hcloud_primary_ip module – Create and manage cloud Primary IPs on the Hetzner Cloud.

Note

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

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

New in hetzner.hcloud 1.8.0

Synopsis

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

Requirements

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

  • hcloud-python >= 1.0.0

  • hcloud-python >= 1.9.0

Parameters

Parameter

Comments

api_token

string / required

This is the API Token for the Hetzner Cloud.

auto_delete

boolean

Delete this Primary IP when the resource it is assigned to is deleted

Choices:

  • false ← (default)

  • true

datacenter

string

Home Location of the Hetzner Cloud Primary IP.

Required if no server is given and Primary IP does not exist.

delete_protection

boolean

Protect the Primary IP for deletion.

Choices:

  • false

  • true

endpoint

string

This is the API Endpoint for the Hetzner Cloud.

Default: "https://api.hetzner.cloud/v1"

id

integer

The ID of the Hetzner Cloud Primary IPs to manage.

Only required if no Primary IP name is given.

labels

dictionary

User-defined labels (key-value pairs).

name

string

The Name of the Hetzner Cloud Primary IPs to manage.

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

state

string

State of the Primary IP.

Choices:

  • "absent"

  • "present" ← (default)

type

string

Type of the Primary IP.

Required if Primary IP does not exist

Choices:

  • "ipv4"

  • "ipv6"

See Also

See also

Documentation for Hetzner Cloud API

Complete reference for the Hetzner Cloud API.

Examples

- name: Create a basic IPv4 Primary IP
  hcloud_primary_ip:
    name: my-primary-ip
    datacenter: fsn1-dc14
    type: ipv4
    state: present
- name: Create a basic IPv6 Primary IP
  hcloud_primary_ip:
    name: my-primary-ip
    datacenter: fsn1-dc14
    type: ipv6
    state: present
- name: Primary IP should be absent
  hcloud_primary_ip:
    name: my-primary-ip
    state: absent

Return Values

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

Key

Description

hcloud_primary_ip

complex

The Primary IP instance

Returned: Always

datacenter

string

Name of the datacenter of the Primary IP

Returned: Always

Sample: "fsn1-dc14"

delete_protection

boolean

True if Primary IP is protected for deletion

Returned: always

Sample: false

id

integer

ID of the Primary IP

Returned: Always

Sample: 12345

ip

string

IP Address of the Primary IP

Returned: Always

Sample: "116.203.104.109"

labels

dictionary

User-defined labels (key-value pairs)

Returned: Always

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

name

string

Name of the Primary IP

Returned: Always

Sample: "my-primary-ip"

type

string

Type of the Primary IP

Returned: Always

Sample: "ipv4"

Authors

  • Lukas Kaemmerling (@lkaemmerling)