From 068668b4bb47cb28fe48cf94c1e92484b634fb88 Mon Sep 17 00:00:00 2001 From: Alex Schultz Date: Tue, 26 Mar 2019 16:52:23 -0600 Subject: [PATCH] Force chrony restart on config change We've seen handlers being inconsitently being ignored for some deployments when we force a handler flush mid-playbook. We'll need to ensure the config is properly loaded if we want to follow up with subsequent chronyc application so it's best to always invoke the restart when the configuration actually changes. Change-Id: I5292f1b1bd65cef340e1e9742463620effc30d26 --- tasks/config.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tasks/config.yml b/tasks/config.yml index 3dffca8..88506c5 100644 --- a/tasks/config.yml +++ b/tasks/config.yml @@ -6,6 +6,7 @@ owner: root group: root mode: 0644 + register: chrony_config notify: Restart chronyd - name: Ensure chronyd is running @@ -13,3 +14,16 @@ name: "{{ chrony_service_name }}" state: "{{ chrony_service_state|default('started') }}" when: chrony_manage_service|bool + +# ansible sometimes ignores handlers when invoked elsewhere. Since we will +# likely want to restart chrony after a configuration update, let's do it here +# always. The handler will still trigger for upgrades/updates later as well. +# This won't have any effect if chrony_manage_service is set to false. +# See also https://github.com/ansible/ansible/issues/37512 +- name: Force chronyd restart + service: + name: "{{ chrony_service_name }}" + state: restarted + when: + - chrony_manage_service|bool + - chrony_config.changed