30 lines
936 B
YAML
30 lines
936 B
YAML
---
|
|
- name: Install chrony configuration file
|
|
template:
|
|
src: chrony.conf.j2
|
|
dest: "{{ chrony_config_file_location }}"
|
|
owner: root
|
|
group: root
|
|
mode: 0644
|
|
register: chrony_config
|
|
notify: Restart chronyd
|
|
|
|
- name: Ensure chronyd is running
|
|
service:
|
|
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
|