ansible/ansible — pull request #3945 by jwriteclub (2013-08-25 17:13:31+00:00)
Title: Added Nameserver Facts to Setup

Added the following three facts to `setup`:

* 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.

This version of this patch implements a single static helper to avoid duplication of code in Network modules and uses python 2.4 compatible `open`, `read`, `close` on the file.

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.

Example Real World Usage
-------------------------------------

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.