hetzner.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 4.2.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.primary_ip
.
New in hetzner.hcloud 1.8.0
Synopsis
Create, update and manage cloud Primary IPs on the Hetzner Cloud.
Aliases: hcloud_primary_ip
Requirements
The below requirements are needed on the host that executes this module.
python-dateutil >= 2.7.5
requests >=2.20
Parameters
Parameter |
Comments |
---|---|
The API Endpoint for the Hetzner Cloud. You can also set this option by using the Default: |
|
The API Token for the Hetzner Cloud. You can also set this option by using the |
|
Delete the Primary IP when the resource it is assigned to is deleted. Choices:
|
|
Home Location of the Hetzner Cloud Primary IP. Required if no server is given and Primary IP does not exist. |
|
Protect the Primary IP for deletion. Choices:
|
|
The ID of the Hetzner Cloud Primary IPs to manage. Only required if no Primary IP name is given. |
|
User-defined labels (key-value pairs). |
|
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. |
|
Name or ID of the Hetzner Cloud Server the Primary IP should be assigned to. The Primary IP cannot be assigned to a running server. Required if no |
|
State of the Primary IP. Choices:
|
|
Type of the Primary IP. Required if Primary IP does not exist Choices:
|
See Also
See also
- Documentation for Hetzner Cloud API
Complete reference for the Hetzner Cloud API.
Examples
- name: Create a IPv4 Primary IP
hetzner.hcloud.primary_ip:
name: my-primary-ip
datacenter: fsn1-dc14
type: ipv4
state: present
- name: Create a IPv6 Primary IP
hetzner.hcloud.primary_ip:
name: my-primary-ip
datacenter: fsn1-dc14
type: ipv6
state: present
- name: Delete a Primary IP
hetzner.hcloud.primary_ip:
name: my-primary-ip
state: absent
- name: Ensure the server is stopped
hetzner.hcloud.server:
name: my-server
state: stopped
- name: Create a Primary IP attached to a Server
hetzner.hcloud.primary_ip:
name: my-primary-ip
server: my-server
type: ipv4
state: present
- name: Ensure the server is started
hetzner.hcloud.server:
name: my-server
state: started
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
The Primary IP instance Returned: Always |
|
ID of the resource the Primary IP is assigned to, null if it is not assigned. Returned: always Sample: |
|
Resource type the Primary IP can be assigned to. Returned: always Sample: |
|
Delete the Primary IP when the resource it is assigned to is deleted. Returned: always Sample: |
|
Name of the datacenter of the Primary IP Returned: Always Sample: |
|
True if Primary IP is protected for deletion Returned: always Sample: |
|
ID of the Primary IP Returned: Always Sample: |
|
IP Address of the Primary IP Returned: Always Sample: |
|
User-defined labels (key-value pairs) Returned: Always Sample: |
|
Name of the Primary IP Returned: Always Sample: |
|
Type of the Primary IP Returned: Always Sample: |