1
0
Fork 0
mirror of https://github.com/ansible-collections/hetzner.hcloud.git synced 2026-02-04 08:01:49 +00:00

feat: deprecate datacenter in primary ips and servers (#773)

##### SUMMARY

Deprecate datacenter in `primary ips` and `servers`.

See
https://docs.hetzner.cloud/changelog#2025-12-16-phasing-out-datacenters.
This commit is contained in:
Jonas L. 2026-01-05 16:44:04 +01:00 committed by GitHub
parent 75770a62d3
commit 10c41f032b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 209 additions and 42 deletions

View file

@ -171,9 +171,12 @@ plugin: hetzner.hcloud.hcloud
# hcloud_image_id: 114690387
# hcloud_image_name: "debian-12"
# hcloud_image_os_flavor: "debian"
## Datacenter
# hcloud_datacenter: "hel1-dc2"
## Location
# hcloud_location: "hel1"
# # The hcloud_datacenter variable is deprecated and will be removed after 1 July 2026.
# # Please use the hcloud_location variable instead.
# # See https://docs.hetzner.cloud/changelog#2025-12-16-phasing-out-datacenters.
# hcloud_datacenter: "hel1-dc2"
## Network
# hcloud_ipv4: "65.109.140.95" # Value is optional!
# hcloud_ipv6: "2a01:4f9:c011:b83f::1" # Value is optional!
@ -185,10 +188,11 @@ plugin: hetzner.hcloud.hcloud
# name: "my-private-network"
# ip: "10.0.0.3"
#
hostname: "my-prefix-{{ hcloud_datacenter }}-{{ hcloud_name }}-{{ hcloud_server_type }}"
hostname: "my-prefix-{{ hcloud_location }}-{{ hcloud_name }}-{{ hcloud_server_type }}"
"""
import sys
import warnings
from ipaddress import IPv6Network
from ansible.errors import AnsibleError
@ -230,7 +234,7 @@ if sys.version_info >= (3, 11):
architecture: str
# Datacenter
datacenter: str
datacenter: str # Deprecated!
location: str
# Labels
@ -322,7 +326,7 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
if self.get_option("locations"):
locations: list[str] = self.get_option("locations")
servers = [s for s in servers if s.datacenter.location.name in locations]
servers = [s for s in servers if s.location.name in locations]
if self.get_option("types"):
server_types: list[str] = self.get_option("types")
@ -365,9 +369,16 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
server_dict["private_ipv4"] = private_net.ip
break
# Datacenter
server_dict["datacenter"] = server.datacenter.name
server_dict["location"] = server.datacenter.location.name
# Location
server_dict["location"] = server.location.name
with warnings.catch_warnings():
warnings.simplefilter("ignore", category=DeprecationWarning)
self.display.warning(
"The `hcloud_datacenter` variable is deprecated and will be removed "
"after 1 July 2026. Please use the `hcloud_location` variable instead. "
"See https://docs.hetzner.cloud/changelog#2025-12-16-phasing-out-datacenters."
)
server_dict["datacenter"] = server.datacenter and server.datacenter.name
# Image
if server.image is not None: