ansible-collections / community.general

Ansible Community General Collection
https://galaxy.ansible.com/ui/repo/published/community/general/
GNU General Public License v3.0
833 stars 1.53k forks source link

[PR #8970/8610223d backport][stable-8] dig lookup plugin: Fix using only last nameserver specified #8985

Closed patchback[bot] closed 1 month ago

patchback[bot] commented 1 month ago

This is a backport of PR #8970 as merged into main (8610223d03d46c02b4190661a62d1977ba8f4a89).

SUMMARY

Currently, when specifying multiple nameservers, only the very last one is actually used. Fix that by collecting all specified nameservers and passing them to the Resolver after the argument processing is done.

ISSUE TYPE
COMPONENT NAME

dig

ADDITIONAL INFORMATION

Currently, when specifying multiple nameservers either using multiple @ns.example.com arguments or by specifying multiple nameservers in a single argument (@ns1.example.com,ns2.example.com), due to a bug only the very last nameserver that is specified is actually used. This is because for every iteration of the for ns in nsset loop, the local list of nameservers is cleared and after adding the currently processed nameserver entry, the whole nameservers list of the Resolver instance is overridden with that new list with just one element. And as far as I can see, when setting that nameserver property, the dnspython library actually overrides the existing list and doesn't do some trickery to append the new nameservers or something like that.

Therefore, the assignment of the nameservers property of the Resolver is moved after the argument processing so all nameservers are added and then collectively written to the nameservers property of the Resolver.