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
This commit is contained in:
Alex Schultz 2019-03-26 16:52:23 -06:00
parent 550aa62372
commit 068668b4bb
1 changed files with 14 additions and 0 deletions

View File

@ -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