From b2cd1b555e6582762c54b887c147f6c9727e813e Mon Sep 17 00:00:00 2001 From: sedrubal Date: Sat, 4 Apr 2026 20:33:34 +0200 Subject: [PATCH] Fix KeyError for 'dnsttl' (#11717) * Fix KeyError for 'dnsttl' I did not further dig into the code. However, since upgrading to the latest version of `community.general`, ansible fails with a weird error message "dnsttl" at a task where `community.general.ipa_dnsrecord` is called. After digging into the code a bit, I found out that it is a KeyError and caused by this line of code. I'm not sure, if it is safe to skip that line and not to set `result["dnsttl"]`. * Add changelog fragment * Adopt suggestion for changelogs/fragments/11717-fix-error-dnsttl.yml Co-authored-by: Felix Fontein --------- Co-authored-by: Felix Fontein --- changelogs/fragments/11717-fix-error-dnsttl.yml | 2 ++ plugins/modules/ipa_dnsrecord.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/11717-fix-error-dnsttl.yml diff --git a/changelogs/fragments/11717-fix-error-dnsttl.yml b/changelogs/fragments/11717-fix-error-dnsttl.yml new file mode 100644 index 0000000000..8b564c6f5b --- /dev/null +++ b/changelogs/fragments/11717-fix-error-dnsttl.yml @@ -0,0 +1,2 @@ +bugfixes: + - ipa_dnsrecord - fix errors when module is used with existing record with default TTL (https://github.com/ansible-collections/community.general/pull/11717). diff --git a/plugins/modules/ipa_dnsrecord.py b/plugins/modules/ipa_dnsrecord.py index e6c8fd2dd5..1cc0ac6ad9 100644 --- a/plugins/modules/ipa_dnsrecord.py +++ b/plugins/modules/ipa_dnsrecord.py @@ -210,7 +210,8 @@ class DNSRecordIPAClient(IPAClient): else: method = "dnsrecord_find" result = self._post_json(method=method, name=zone_name, item={"idnsname": record_name, "all": True}) - result["dnsttl"] = [int(v) for v in result["dnsttl"]] + if "dnsttl" in result: + result["dnsttl"] = [int(v) for v in result["dnsttl"]] return result def dnsrecord_add(self, zone_name=None, record_name=None, details=None):