mirror of
https://github.com/ansible-collections/hetzner.hcloud.git
synced 2026-02-04 08:01:49 +00:00
feat: deprecated datacenter in primary ips
This commit is contained in:
parent
54029e1725
commit
a546c87506
3 changed files with 50 additions and 12 deletions
|
|
@ -11,7 +11,8 @@ def prepare_result(o: BoundPrimaryIP):
|
|||
"name": o.name,
|
||||
"ip": o.ip,
|
||||
"type": o.type,
|
||||
"datacenter": o.datacenter.name,
|
||||
"location": o.location.name,
|
||||
"datacenter": o.datacenter and o.datacenter.name,
|
||||
"labels": o.labels,
|
||||
"delete_protection": o.protection["delete"],
|
||||
"assignee_id": o.assignee_id,
|
||||
|
|
|
|||
|
|
@ -24,17 +24,25 @@ options:
|
|||
id:
|
||||
description:
|
||||
- The ID of the Hetzner Cloud Primary IPs to manage.
|
||||
- Only required if no Primary IP I(name) is given.
|
||||
- Only required if no Primary IP O(name) is given.
|
||||
type: int
|
||||
name:
|
||||
description:
|
||||
- The Name of the Hetzner Cloud Primary IPs to manage.
|
||||
- Only required if no Primary IP I(id) is given or a Primary IP does not exist.
|
||||
- Only required if no Primary IP O(id) is given or a Primary IP does not exist.
|
||||
type: str
|
||||
location:
|
||||
description:
|
||||
- ID or name of the Location the Hetzner Cloud Primary IP will be bound to.
|
||||
- Required if no O(server) is given and Primary IP does not exist.
|
||||
type: str
|
||||
datacenter:
|
||||
description:
|
||||
- B(Deprecated:) The O(datacenter) argument is deprecated and will be removed
|
||||
after 1 July 2026. Please use the O(location) argument instead.
|
||||
See https://docs.hetzner.cloud/changelog#2025-12-16-phasing-out-datacenters.
|
||||
- Home Location of the Hetzner Cloud Primary IP.
|
||||
- Required if no I(server) is given and Primary IP does not exist.
|
||||
- Required if no O(server) is given and Primary IP does not exist.
|
||||
type: str
|
||||
server:
|
||||
description:
|
||||
|
|
@ -76,14 +84,14 @@ EXAMPLES = """
|
|||
- name: Create a IPv4 Primary IP
|
||||
hetzner.hcloud.primary_ip:
|
||||
name: my-primary-ip
|
||||
datacenter: fsn1-dc14
|
||||
location: fsn1
|
||||
type: ipv4
|
||||
state: present
|
||||
|
||||
- name: Create a IPv6 Primary IP
|
||||
hetzner.hcloud.primary_ip:
|
||||
name: my-primary-ip
|
||||
datacenter: fsn1-dc14
|
||||
location: fsn1
|
||||
type: ipv6
|
||||
state: present
|
||||
|
||||
|
|
@ -134,8 +142,18 @@ hcloud_primary_ip:
|
|||
type: str
|
||||
returned: Always
|
||||
sample: ipv4
|
||||
location:
|
||||
description: Name of the Location of the Primary IP
|
||||
type: str
|
||||
returned: Always
|
||||
sample: fsn1
|
||||
datacenter:
|
||||
description: Name of the datacenter of the Primary IP
|
||||
description: |
|
||||
Name of the datacenter of the Primary IP
|
||||
|
||||
B(Deprecated:) The R(hcloud_primary_ip.datacenter) value is deprecated and will be removed
|
||||
after 1 July 2026. Please use the R(hcloud_primary_ip.location) value instead.
|
||||
See https://docs.hetzner.cloud/changelog#2025-12-16-phasing-out-datacenters.
|
||||
type: str
|
||||
returned: Always
|
||||
sample: fsn1-dc14
|
||||
|
|
@ -198,14 +216,21 @@ class AnsiblePrimaryIP(AnsibleHCloud):
|
|||
def _create(self):
|
||||
self.fail_on_invalid_params(
|
||||
required=["name", "type"],
|
||||
required_one_of=[["server", "datacenter"]],
|
||||
required_one_of=[["server", "location", "datacenter"]],
|
||||
)
|
||||
params = {
|
||||
"name": self.module.params.get("name"),
|
||||
"type": self.module.params.get("type"),
|
||||
}
|
||||
|
||||
if (value := self.module.params.get("datacenter")) is not None:
|
||||
if (value := self.module.params.get("location")) is not None:
|
||||
params["location"] = self._client_get_by_name_or_id("locations", value)
|
||||
elif (value := self.module.params.get("datacenter")) is not None:
|
||||
self.module.warn(
|
||||
"The `datacenter` argument is deprecated and will be removed "
|
||||
"after 1 July 2026. Please use the `location` argument instead. "
|
||||
"See https://docs.hetzner.cloud/changelog#2025-12-16-phasing-out-datacenters."
|
||||
)
|
||||
params["datacenter"] = self.client.datacenters.get_by_name(value)
|
||||
elif (value := self.module.params.get("server")) is not None:
|
||||
server: BoundServer = self._client_get_by_name_or_id("servers", value)
|
||||
|
|
@ -287,7 +312,8 @@ class AnsiblePrimaryIP(AnsibleHCloud):
|
|||
argument_spec=dict(
|
||||
id={"type": "int"},
|
||||
name={"type": "str"},
|
||||
datacenter={"type": "str"},
|
||||
location={"type": "str"},
|
||||
datacenter={"type": "str", "removed_at_date": "2026-07-01"},
|
||||
server={"type": "str"},
|
||||
auto_delete={"type": "bool", "default": False},
|
||||
type={"choices": ["ipv4", "ipv6"]},
|
||||
|
|
|
|||
|
|
@ -99,8 +99,18 @@ hcloud_primary_ip_info:
|
|||
returned: always
|
||||
type: str
|
||||
sample: server
|
||||
location:
|
||||
description: Location where the Primary IP was created in.
|
||||
returned: always
|
||||
type: str
|
||||
sample: fsn1
|
||||
home_location:
|
||||
description: Location with datacenter where the Primary IP was created in
|
||||
description: |
|
||||
Datacenter where the Primary IP was created in.
|
||||
|
||||
B(Deprecated:) The R(hcloud_primary_ip_info.home_location) value is deprecated and will be removed
|
||||
after 1 July 2026. Please use the R(hcloud_primary_ip_info.location) value instead.
|
||||
See https://docs.hetzner.cloud/changelog#2025-12-16-phasing-out-datacenters.
|
||||
returned: always
|
||||
type: str
|
||||
sample: fsn1-dc1
|
||||
|
|
@ -152,7 +162,8 @@ class AnsibleHCloudPrimaryIPInfo(AnsibleHCloud):
|
|||
"assignee_id": primary_ip.assignee_id if primary_ip.assignee_id is not None else None,
|
||||
"assignee_type": primary_ip.assignee_type,
|
||||
"auto_delete": primary_ip.auto_delete,
|
||||
"home_location": primary_ip.datacenter.name,
|
||||
"location": primary_ip.location.name,
|
||||
"home_location": primary_ip.datacenter and primary_ip.datacenter.name,
|
||||
"dns_ptr": primary_ip.dns_ptr[0]["dns_ptr"] if len(primary_ip.dns_ptr) else None,
|
||||
"labels": primary_ip.labels,
|
||||
"delete_protection": primary_ip.protection["delete"],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue