From b92aa47b47d918720a70fb7ab07ae6a93d934f32 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky Date: Sun, 31 May 2026 14:05:46 +1200 Subject: [PATCH 1/3] fix(udm_dns_record): normalize IPv6 addresses before comparison UCS stores IPv6 addresses in expanded form; providing a shortened address causes obj.diff() to always detect a difference and report changed=True. Normalize IPv6 values in the data dict to exploded form before updating the Univention object. Fixes #317 --- plugins/modules/udm_dns_record.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/plugins/modules/udm_dns_record.py b/plugins/modules/udm_dns_record.py index a2629a939e..d449dbda52 100644 --- a/plugins/modules/udm_dns_record.py +++ b/plugins/modules/udm_dns_record.py @@ -114,6 +114,28 @@ with deps.declare("ipaddress"): import ipaddress +def _normalize_ip(value: str) -> str: + try: + addr = ipaddress.ip_address(value) + if isinstance(addr, ipaddress.IPv6Address): + return addr.exploded + except ValueError: + pass + return value + + +def _normalize_data_ips(data: dict) -> dict: + result = {} + for key, value in data.items(): + if isinstance(value, list): + result[key] = [_normalize_ip(v) if isinstance(v, str) else v for v in value] + elif isinstance(value, str): + result[key] = _normalize_ip(value) + else: + result[key] = value + return result + + def main(): module = AnsibleModule( argument_spec=dict( @@ -185,7 +207,7 @@ def main(): else: obj["name"] = name - obj.update(data) + obj.update(_normalize_data_ips(data)) diff = obj.diff() changed = obj.diff() != [] if not module.check_mode: From fabd544d68f3082bb486665f71b7d4d09a827f2a Mon Sep 17 00:00:00 2001 From: Alexei Znamensky Date: Sun, 31 May 2026 14:07:29 +1200 Subject: [PATCH 2/3] changelog: add fragment for PR 12149 --- changelogs/fragments/12149-udm-dns-record-ipv6-idempotency.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changelogs/fragments/12149-udm-dns-record-ipv6-idempotency.yml diff --git a/changelogs/fragments/12149-udm-dns-record-ipv6-idempotency.yml b/changelogs/fragments/12149-udm-dns-record-ipv6-idempotency.yml new file mode 100644 index 0000000000..c2c5cccec0 --- /dev/null +++ b/changelogs/fragments/12149-udm-dns-record-ipv6-idempotency.yml @@ -0,0 +1,2 @@ +bugfixes: + - "udm_dns_record - normalize IPv6 addresses in ``data`` to expanded form to fix idempotency (https://github.com/ansible-collections/community.general/issues/317, https://github.com/ansible-collections/community.general/pull/12149)." From a16ba6eb1c53307430f14cb848acec9a374def57 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky Date: Sun, 31 May 2026 14:38:17 +1200 Subject: [PATCH 3/3] add type hint --- plugins/modules/udm_dns_record.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/udm_dns_record.py b/plugins/modules/udm_dns_record.py index d449dbda52..20415ffcd7 100644 --- a/plugins/modules/udm_dns_record.py +++ b/plugins/modules/udm_dns_record.py @@ -125,7 +125,7 @@ def _normalize_ip(value: str) -> str: def _normalize_data_ips(data: dict) -> dict: - result = {} + result: dict = {} for key, value in data.items(): if isinstance(value, list): result[key] = [_normalize_ip(v) if isinstance(v, str) else v for v in value]