diff --git a/CHANGELOG.md b/CHANGELOG.md index 193f58d..ee938c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ### Enhancements * Allow to install Resolvconf. +* Manage Resolvconf base configuration file. ## v1.0.3 diff --git a/README.md b/README.md index d04ab3f..2c6eb07 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ Manage some basics configuration for IPR's servers. * **basics__proxmox_*disable** : Allow to disable the management of some files by Proxmox for LXC containers [default : `[]`]. * **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 }}`]. ## Example Playbook @@ -60,7 +61,8 @@ 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. +* 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). ## Development diff --git a/defaults/main.yml b/defaults/main.yml index 5e9255e..fa24cbb 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -36,5 +36,13 @@ basics__resolvconf_packages: basics__resolvconf_enabled: False # ]]] +# .. envvar:: basics__resolvconf_domains [[[ +# +# List of domains used as search suffixes when resolving host names. +# +basics__resolvconf_domains: + - '{{ ansible_domain }}' + + # ]]] # ]]] diff --git a/tasks/main.yml b/tasks/main.yml index be2061f..31c4990 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -57,3 +57,12 @@ - '{{ basics__resolvconf_packages }}' when: basics__resolvconf_enabled|bool +- name: Configure Resolvconf with domains + template: + src: '../templates/etc/resolvconf/resolv.conf.d/base.j2' + dest: '/etc/resolvconf/resolv.conf.d/base' + owner: root + group: root + mode: '0644' + when: basics__resolvconf_enabled|bool + diff --git a/templates/etc/resolvconf/resolv.conf.d/base.j2 b/templates/etc/resolvconf/resolv.conf.d/base.j2 new file mode 100644 index 0000000..0776981 --- /dev/null +++ b/templates/etc/resolvconf/resolv.conf.d/base.j2 @@ -0,0 +1,8 @@ +# This file is managed remotely, all changes will be lost +{% for server in ansible_dns['nameservers'] %} +nameserver {{ server }} +{% endfor %} +{% for domain in basics__resolvconf_domains %} +domain {{ domain }} +search {{ domain }} +{% endfor %}