ansible/ansible — pull request #5508 by jwriteclub (2014-01-05 20:10:56+00:00)
Title: Added Name Server Facts to the Setup Module

Added Name Server Facts to the Setup Module
====================================

New Facts
--------------

* all_nameservers: A list of IP addresses of all configured name servers.
* default_nameserver: The first IP address in all_nameservers.
* resolv_domain: The value of the 'domain' entry used for searching non-dot terminated domains.

All data are taken from /etc/resolv.conf using http://pic.dhe.ibm.com/infocenter/aix/v6r1/index.jsp?topic=%2Fcom.ibm.aix.files%2Fdoc%2Faixfiles%2Fresolv.conf.htm as a file format reference.

Rationale For This Change
------------------------------------

1. `resolv.conf` is common across systems and has a well defined format, so these changes are likely to result in useful facts on most systems.
1. It is certainly *possible* to list resolvers in vars files related to each host. As the resolvers are facts about the host, it seems to make more sense to provide this information as setup facts.
1. These facts are notably missing from the wealth of facts which *are* available about the networking subsystem as part of the setup module. As a result information about the system's networking setup is incomplete.

Examples of Real World Usage
-----------------------------------------

1. Several nginx modules (including `proxy` and `ocsp_staple`) require a DNS name server specified in the nginx configuration files. Providing these facts allows straightforward creation of compatible configuration files using only the template action.
1. These facts may be used to allow an Ansible script to test a host's DNS resolution capabilities by explicitly running DNS queries against the host's resolvers from both within and without the host.
1. These facts are useful in multi-machine deployments where Ansible manages gdnsd, or other DNS resolvers which need to be configured with upstream resolvers.

Changes Since the Previous ver. of this Pull Request
-----------------------------------------------------------------------

Implements these facts using basic file I/O rather than running external commands. Added additional discussion as to the rational of this patch.