diff --git a/changelogs/fragments/7219-fix-nsupdate-cname.yaml b/changelogs/fragments/7219-fix-nsupdate-cname.yaml new file mode 100644 index 00000000000..bd58eb883fb --- /dev/null +++ b/changelogs/fragments/7219-fix-nsupdate-cname.yaml @@ -0,0 +1,2 @@ +bugfixes: + - nsupdate - fix a possible ``list index out of range`` exception (https://github.com/ansible-collections/community.general/issues/836). diff --git a/plugins/modules/nsupdate.py b/plugins/modules/nsupdate.py index ac3c695cf23..0d8c1ea1035 100644 --- a/plugins/modules/nsupdate.py +++ b/plugins/modules/nsupdate.py @@ -467,10 +467,8 @@ def ttl_changed(self): if lookup.rcode() != dns.rcode.NOERROR: self.module.fail_json(msg='Failed to lookup TTL of existing matching record.') - 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 + current_ttl = lookup.answer[0].ttl if lookup.answer else lookup.authority[0].ttl + return current_ttl != self.module.params['ttl']