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 6.9.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.primary_ip.
New in hetzner.hcloud 1.8.0
Synopsis
- Create, update and manage cloud Primary IPs on the Hetzner Cloud.
- To manage the DNS pointer of a Primary IP, use the hetzner.hcloud.rdns module.
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 |
|---|---|
api_endpoint aliases: endpoint string | The endpoint for the Hetzner Cloud API. You can also set this option by using the Default: |
api_endpoint_hetzner string | The endpoint for the Hetzner API. You can also set this option by using the Default: |
api_token string / required | The token for the Hetzner Cloud API. You can also set this option by using the |
auto_delete boolean | Delete the Primary IP when the resource it is assigned to is deleted. Choices:
|
datacenter string | Deprecated: The Home Location of the Hetzner Cloud Primary IP. Required if no |
delete_protection boolean | Protect the Primary IP for deletion. Choices:
|
id integer | The ID of the Hetzner Cloud Primary IPs to manage. Only required if no Primary IP |
labels dictionary | User-defined labels (key-value pairs). |
location string | ID or name of the Location the Hetzner Cloud Primary IP will be bound to. Required if no |
name string | The Name of the Hetzner Cloud Primary IPs to manage. Only required if no Primary IP |
server string | 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 Use |
state string | State of the Primary IP. Choices:
|
type string | Type of the Primary IP. Required if Primary IP does not exist Choices:
|
See Also
See also
- Documentation for Hetzner APIs
-
Complete reference for the Hetzner APIs.
Examples
- name: Create a IPv4 Primary IP
hetzner.hcloud.primary_ip:
name: my-primary-ip
location: fsn1
type: ipv4
state: present
- name: Create a IPv6 Primary IP
hetzner.hcloud.primary_ip:
name: my-primary-ip
location: fsn1
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
- name: Unassign a Primary IP from a Server
hetzner.hcloud.primary_ip:
name: my-primary-ip
type: ipv4
server: null
state: present
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key | Description |
|---|---|
hcloud_primary_ip dictionary | The Primary IP instance Returned: Always |
|
assignee_id integer |
ID of the resource where the Primary IP is assigned to, none if unassigned. Returned: always Sample: |
|
assignee_type string |
Type of the resource where the Primary IP is assigned to. Returned: always Sample: |
|
auto_delete boolean |
Delete the Primary IP when the resource it is assigned to is deleted. Returned: always Sample: |
|
datacenter string |
Name of the datacenter of the Primary IP Deprecated: The Returned: Always Sample: |
|
delete_protection boolean |
True if Primary IP is protected for deletion Returned: always Sample: |
|
id integer |
ID of the Primary IP Returned: Always Sample: |
|
ip string |
IP Address of the Primary IP Returned: Always Sample: |
|
labels dictionary |
User-defined labels (key-value pairs) Returned: Always Sample: |
|
location string |
Name of the Location of the Primary IP Returned: Always Sample: |
|
name string |
Name of the Primary IP Returned: Always Sample: |
|
type string |
Type of the Primary IP Returned: Always Sample: |
Collection links
© 2012–2018 Michael DeHaan
© 2018–2025 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/projects/ansible/latest/collections/hetzner/hcloud/primary_ip_module.html