Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to resolve names using search domains #200

Closed
nightgryphon opened this issue May 8, 2024 · 3 comments
Closed

Fail to resolve names using search domains #200

nightgryphon opened this issue May 8, 2024 · 3 comments

Comments

@nightgryphon
Copy link

SUMMARY

Does not resolve names which require use of system search domains.
It looks '.' is forcefully added to name and this behavior is NOT DESCRIBED and can't be overriden.
The community.general.dig lookup work fine with the same input.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

community.dns.lookup lookup

ANSIBLE VERSION
ansible [core 2.16.5]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (/usr/bin/python3)
  jinja version = 3.0.3
  libyaml = True
COLLECTION VERSION
# /usr/lib/python3/dist-packages/ansible_collections
Collection    Version
------------- -------
community.dns 2.8.3
CONFIGURATION
CONFIG_FILE() = /etc/ansible/ansible.cfg
OS / ENVIRONMENT

Ubuntu 22.04.3 LTS

STEPS TO REPRODUCE

Try to resolve short host names which require search domain usage

# nslookup nifi-1
Server:         127.0.0.53
Address:        127.0.0.53#53

Non-authoritative answer:
Name:   nifi-1.cluster.home
Address: 172.16.0.125
- debug:
    msg: "{{ query('community.dns.lookup', 'nifi-1') }}"
EXPECTED RESULTS

['172.16.0.125']

ACTUAL RESULTS
fatal: [nifi-1]: FAILED! => {"msg": "Unexpected DNS error for nifi-1: All nameservers failed to answer the query nifi-1. IN A: Server 127.0.0.53 UDP port 53 answered SERVFAIL"}
@felixfontein
Copy link
Collaborator

The difference between the dig lookup and this one is that dig uses Resolver.query(), which calls Resolver.resolve() with search=True; this lookup uses Resolver.resolve() directly, which defaults to search=False. (Also the lookup uses dns.name.from_unicode(to_text(target)) to parse the input, which converts the input to absolute unless root=None is passed to from_unicode().)

@felixfontein
Copy link
Collaborator

The plugins in 3.0.0 will do this by default, and for the plugins in 2.x.y it is now documented (resp. will be with the next release).

@nightgryphon
Copy link
Author

Thank you!
Has to tell that was the fastest reaction and bugfix at github in my practice :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants