2018-12-12 19:15:00 +08:00
|
|
|
---
|
2019-02-05 17:26:03 +08:00
|
|
|
# Installation of NTP daemons needs to be a separate task since installations
|
|
|
|
# can't happen on Atomic
|
|
|
|
- name: install the ntp daemon
|
|
|
|
when: not is_atomic
|
2018-12-12 19:15:00 +08:00
|
|
|
block:
|
2019-02-05 17:26:03 +08:00
|
|
|
- name: install ntpd
|
|
|
|
package:
|
|
|
|
name: ntp
|
|
|
|
state: present
|
|
|
|
register: result
|
|
|
|
until: result is succeeded
|
2019-04-01 23:46:15 +08:00
|
|
|
when: ntp_daemon_type == "ntpd"
|
2019-02-05 17:26:03 +08:00
|
|
|
|
|
|
|
- name: install chrony
|
|
|
|
package:
|
|
|
|
name: chrony
|
|
|
|
state: present
|
|
|
|
register: result
|
|
|
|
until: result is succeeded
|
2019-04-01 23:46:15 +08:00
|
|
|
when: ntp_daemon_type == "chronyd"
|
2019-02-05 17:26:03 +08:00
|
|
|
|
|
|
|
- name: enable the ntp daemon and disable the rest
|
|
|
|
block:
|
|
|
|
- name: enable timesyncing on timesyncd
|
2018-12-12 19:15:00 +08:00
|
|
|
command: timedatectl set-ntp on
|
2018-12-12 19:23:23 +08:00
|
|
|
notify:
|
|
|
|
- disable ntpd
|
|
|
|
- disable chronyd
|
2019-04-01 23:46:15 +08:00
|
|
|
when: ntp_daemon_type == "timesyncd"
|
2018-12-12 19:15:00 +08:00
|
|
|
|
|
|
|
- name: disable time sync using timesyncd if we are not using it
|
|
|
|
command: timedatectl set-ntp no
|
2019-04-01 23:46:15 +08:00
|
|
|
when: ntp_daemon_type != "timesyncd"
|
2018-12-12 19:15:00 +08:00
|
|
|
|
2019-02-05 17:26:03 +08:00
|
|
|
- name: enable ntpd
|
|
|
|
service:
|
|
|
|
name: "{{ ntp_service_name }}"
|
|
|
|
enabled: yes
|
|
|
|
state: started
|
|
|
|
notify:
|
|
|
|
- disable chronyd
|
|
|
|
- disable timesyncd
|
2019-04-01 23:46:15 +08:00
|
|
|
when: ntp_daemon_type == "ntpd"
|
2018-12-12 19:15:00 +08:00
|
|
|
|
2019-02-05 17:26:03 +08:00
|
|
|
- name: enable chronyd
|
|
|
|
service:
|
|
|
|
name: chronyd
|
|
|
|
enabled: yes
|
|
|
|
state: started
|
|
|
|
notify:
|
|
|
|
- disable ntpd
|
|
|
|
- disable timesyncd
|
2019-04-01 23:46:15 +08:00
|
|
|
when: ntp_daemon_type == "chronyd"
|