From cf74b17bb952648faa5a3fb097cbd0e5e7cc0246 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Tue, 15 May 2018 11:27:41 +0200 Subject: [PATCH] Resolvconf vars use facts values by default --- CHANGELOG.md | 1 + README.md | 3 ++- defaults/main.yml | 8 ++++++++ templates/etc/resolvconf/resolv.conf.d/base.j2 | 2 +- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a1c372..6893895 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * Allow to install Resolvconf. * Manage Resolvconf base configuration file. * Restart Resolvconf service if any modification on configuration file. +* Resolvconf default configuration is set from ansible facts. ## v1.0.3 diff --git a/README.md b/README.md index 67ea3da..3eef4cd 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ Manage some basics configuration for IPR's servers. * **basics__resolvconf_packages** : List of Resolvconf packages to install [default : `resolvconf`]. * **basics__resolvconf_enabled** : Enable or disable support for Resolvconf [default : `False`]. * **basics__resolvconf_domains** : List of domains used as search suffixes with Resolvconf [default : `{{ ansible_domain }}`]. +* **basics__resolvconf_nameservers** : List of nameservers to use to resolv host names with Resolvconf [default : `{{ ansible_dns.nameservers }}`]. * **basics__resolvconf_service_name** : The Resolvconf service name to manage [default : `resolvconf`]. ## Example Playbook @@ -63,7 +64,7 @@ For LXC containers, you also have the possibility to disable the management of s ## Resolvconf * If specified, Resolvconf is installed to fix the domain's informations given by the DHCP server. -* Configure a default configuration file with the given informations (list of domains) and system informations (list of nameserver). +* Configure a default configuration file with the given informations (list of domains and nameservers). * Ensure to restart the service if any modification in configuration file. ## Development diff --git a/defaults/main.yml b/defaults/main.yml index a693cf5..e192c2a 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -24,6 +24,7 @@ basics__proxmox_host_disable: [] # .. envvar:: basics__resolvconf_packages [[[ # # List of Resolvconf packages to install. +# basics__resolvconf_packages: - 'resolvconf' @@ -43,6 +44,13 @@ basics__resolvconf_enabled: False basics__resolvconf_domains: - '{{ ansible_domain }}' + # ]]] +# .. envvar:: basics__resolvconf_nameservers [[[ +# +# List of nameservers to use to resolv host names. +# +basics__resolvconf_nameservers: '{{ ansible_dns.nameservers }}' + # ]]] # .. envvar:: basics__resolvconf_service_name [[[ # diff --git a/templates/etc/resolvconf/resolv.conf.d/base.j2 b/templates/etc/resolvconf/resolv.conf.d/base.j2 index 0776981..f86b8e4 100644 --- a/templates/etc/resolvconf/resolv.conf.d/base.j2 +++ b/templates/etc/resolvconf/resolv.conf.d/base.j2 @@ -1,5 +1,5 @@ # This file is managed remotely, all changes will be lost -{% for server in ansible_dns['nameservers'] %} +{% for server in basics__resolvconf_nameservers %} nameserver {{ server }} {% endfor %} {% for domain in basics__resolvconf_domains %}