Skip to content

Commit

Permalink
nsupdate: fix 'index out of range' error when changing NS records (#8614
Browse files Browse the repository at this point in the history
)

* nsupdate: fix 'index out of range' error when changing NS records

* add clog fragment

* Update changelogs/fragments/8614-nsupdate-index-out-of-range.yml

Co-authored-by: Felix Fontein <[email protected]>

---------

Co-authored-by: Felix Fontein <[email protected]>
  • Loading branch information
artw and felixfontein authored Jul 14, 2024
1 parent 6cefde6 commit 9dd2b71
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changelogs/fragments/8614-nsupdate-index-out-of-range.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- "nsupdate - fix 'index out of range' error when changing NS records by falling back to authority section of the response (https://github.com/ansible-collections/community.general/issues/8612, https://github.com/ansible-collections/community.general/pull/8614)."
3 changes: 2 additions & 1 deletion plugins/modules/nsupdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,8 @@ def modify_record(self):
except (socket_error, dns.exception.Timeout) as e:
self.module.fail_json(msg='DNS server error: (%s): %s' % (e.__class__.__name__, to_native(e)))

entries_to_remove = [n.to_text() for n in lookup.answer[0].items if n.to_text() not in self.value]
lookup_result = lookup.answer[0] if lookup.answer else lookup.authority[0]
entries_to_remove = [n.to_text() for n in lookup_result.items if n.to_text() not in self.value]
else:
update.delete(self.module.params['record'], self.module.params['type'])

Expand Down

0 comments on commit 9dd2b71

Please sign in to comment.