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

dig lookup: Allow to pass port for DNS lookup #8966

Closed JaegerMaKn closed 1 month ago

JaegerMaKn commented 1 month ago
SUMMARY

Add new option port to the dig lookup module to specify which port is to be used for DNS query. This is necessary for setups in which a (custom/internal) DNS server listens on a non-default port.

ISSUE TYPE
COMPONENT NAME

dig

ADDITIONAL INFORMATION

dnspython accepts a port as part of the nameserver and not, like the other optioins that are currently present in the dig module, to be passed to the query function.

Currently, the nameservers are passed as strings which leads dnspython to create Nameserver objects out of them using the port that is currently set in the Resolver instance. That creation of Nameserver objects is done right when the nameservers property is set. If a port is to be set by us, the port attribute of the Resolver needs to be set before the nameservers are passed to the Resolver so when the nameservers are passed, that new port is used to create the Nameserver objects. Therefore, the assignment of the nameservers property of the Resolver is moved after the argument processing so the port attribute is (if it's given) definitely set before the nameservers property.

ansibullbot commented 1 month ago

cc @jpmens click here for bot help

JaegerMaKn commented 1 month ago

Thanks for your review! I've applied the suggested changes

JaegerMaKn commented 1 month ago

Created separate PR with just the multi-nameservers-bugfix as #8970

felixfontein commented 1 month ago

This will likely need a rebase to resolve the conflict once #8970 has been merged.

felixfontein commented 1 month ago

This now needs a rebase.

JaegerMaKn commented 1 month ago

Rebased

patchback[bot] commented 1 month ago

Backport to stable-9: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-9/5e6b8e53274095c7a62b8b4dadf2a9c18ac2e562/pr-8966

Backported as https://github.com/ansible-collections/community.general/pull/9004

🤖 @patchback I'm built with octomachinery and my source is open — https://github.com/sanitizers/patchback-github-app.

felixfontein commented 1 month ago

@JaegerMaKn thanks for your contribution!