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

/etc/resolv.conf facts #2

Open
ahuffman opened this issue Jul 24, 2019 · 4 comments
Open

/etc/resolv.conf facts #2

ahuffman opened this issue Jul 24, 2019 · 4 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@ahuffman
Copy link
Owner

Build a fact collector for /etc/resolv.conf that has data structure similar to https://github.com/ahuffman/ansible-resolv.

Preferably the facts would reside under ansible_facts['resolv.conf']: with dictionaries for nameservers, domain, search, and options.

@ahuffman ahuffman added enhancement New feature or request help wanted Extra attention is needed labels Jul 24, 2019
@bleung
Copy link

bleung commented Aug 24, 2019

This is already available as an ansible fact under ansible_dns

[bleung@bleung ~]$ ansible localhost -m setup | grep -A10 ansible_dns
        "ansible_dns": {
            "nameservers": [
                "192.168.1.1"
            ],
            "search": [
                "home"
            ]
        },
        "ansible_domain": "home",
        "ansible_effective_group_id": 1000,
        "ansible_effective_user_id": 1000,

@ahuffman
Copy link
Owner Author

Not exactly all of it though. We want to gather the /etc/resolv.conf similar to the structure found in this role: https://github.com/ahuffman/ansible-resolv

@bleung
Copy link

bleung commented Aug 26, 2019

I created a more extensive resolv.conf as an example and checked the ansible facts. This is what I get:

[bleung@bleung workspace]$ cat /etc/resolv.conf
# Generated by NetworkManager
search fios-router.home example.com
nameserver 192.168.1.1
nameserver 8.8.8.8
nameserver 8.8.4.4
domain example.com
options rotate timeout:1
sortlist 
[bleung@bleung workspace]$ ansible localhost -m setup | grep -A17 ansible_dns
        "ansible_dns": {
            "domain": "example.com",
            "nameservers": [
                "192.168.1.1",
                "8.8.8.8",
                "8.8.4.4"
            ],
            "options": {
                "rotate": true,
                "timeout": "1"
            },
            "search": [
                "fios-router.home",
                "example.com"
            ],
            "sortlist": []
        },
        "ansible_domain": "",

My understanding of resolv.conf is pretty basic, but does this look more like what you're trying to gather from a server?

@ahuffman
Copy link
Owner Author

Yes actually. I had not noticed this was a built-in fact. It's pretty close to what I would want to gather. The only thing I do not like is the way that the options come out as a dictionary, which makes it slightly more difficult to template out, but I can work with it for the most part. I'd prefer the options to come out as a list with just:

options:
  - rotate
  - timeout:1

Maybe a PR on the Ansible project would be a good approach for this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants