From f86967ff8d8b8fe47697bc881ad926cbea48f3d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Tue, 15 May 2018 11:15:39 +0200 Subject: [PATCH] Manage Resolvconf service --- CHANGELOG.md | 1 + README.md | 2 ++ defaults/main.yml | 6 ++++++ handlers/main.yml | 5 +++++ tasks/main.yml | 2 +- 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee938c3..7a1c372 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### Enhancements * Allow to install Resolvconf. * Manage Resolvconf base configuration file. +* Restart Resolvconf service if any modification on configuration file. ## v1.0.3 diff --git a/README.md b/README.md index 2c6eb07..67ea3da 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_service_name** : The Resolvconf service name to manage [default : `resolvconf`]. ## Example Playbook @@ -63,6 +64,7 @@ For LXC containers, you also have the possibility to disable the management of s * 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). +* Ensure to restart the service if any modification in configuration file. ## Development diff --git a/defaults/main.yml b/defaults/main.yml index fa24cbb..a693cf5 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -44,5 +44,11 @@ basics__resolvconf_domains: - '{{ ansible_domain }}' # ]]] +# .. envvar:: basics__resolvconf_service_name [[[ +# +# The Resolvconf service name to manage. +basics__resolvconf_service_name: 'resolvconf' + + # ]]] # ]]] diff --git a/handlers/main.yml b/handlers/main.yml index 1258780..4216f44 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,2 +1,7 @@ --- # handlers file for basics +- name: restart resolvconf service + service: + name: '{{ basics__resolvconf_service_name }}' + state: '{{ "restarted" if (basics__resolvconf_enabled | bool) }}' + enabled: '{{ basics__resolvconf_enabled | bool }}' diff --git a/tasks/main.yml b/tasks/main.yml index 31c4990..6ce75b8 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -65,4 +65,4 @@ group: root mode: '0644' when: basics__resolvconf_enabled|bool - + notify: ['restart resolvconf service']