diff --git a/changelogs/fragments/5112-fix-nsupdate-ns-entry.yaml b/changelogs/fragments/5112-fix-nsupdate-ns-entry.yaml new file mode 100644 index 0000000000..c5f8653fd6 --- /dev/null +++ b/changelogs/fragments/5112-fix-nsupdate-ns-entry.yaml @@ -0,0 +1,2 @@ +bugfixes: + - nsupdate - compatibility with NS records (https://github.com/ansible-collections/community.general/pull/5112). diff --git a/plugins/modules/net_tools/nsupdate.py b/plugins/modules/net_tools/nsupdate.py index 9f29d4b5fd..512e44da2f 100644 --- a/plugins/modules/net_tools/nsupdate.py +++ b/plugins/modules/net_tools/nsupdate.py @@ -427,7 +427,10 @@ class RecordManager(object): if lookup.rcode() != dns.rcode.NOERROR: self.module.fail_json(msg='Failed to lookup TTL of existing matching record.') - current_ttl = lookup.answer[0].ttl + if self.module.params['type'] == 'NS': + current_ttl = lookup.answer[0].ttl if lookup.answer else lookup.authority[0].ttl + else: + current_ttl = lookup.answer[0].ttl return current_ttl != self.module.params['ttl']