2018-12-12 19:15:00 +08:00
|
|
|
---
|
2019-12-05 06:14:54 +08:00
|
|
|
- name: set ntp service and chrony daemon name for Debian family
|
|
|
|
set_fact:
|
|
|
|
chrony_daemon_name: chrony
|
|
|
|
ntp_service_name: ntp
|
2021-03-03 22:43:50 +08:00
|
|
|
when: ansible_facts['os_family'] == 'Debian'
|
2019-12-05 06:14:54 +08:00
|
|
|
|
|
|
|
- name: set ntp service and chrony daemon name for RedHat and Suse family
|
|
|
|
set_fact:
|
|
|
|
chrony_daemon_name: chronyd
|
|
|
|
ntp_service_name: ntpd
|
2021-03-03 22:43:50 +08:00
|
|
|
when: ansible_facts['os_family'] in ['RedHat', 'Suse']
|
2019-12-05 06:14:54 +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
|
2019-05-22 16:02:42 +08:00
|
|
|
when: not is_atomic | bool
|
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:
|
2019-06-12 17:09:44 +08:00
|
|
|
name: "{{ chrony_daemon_name }}"
|
2019-02-05 17:26:03 +08:00
|
|
|
enabled: yes
|
|
|
|
state: started
|
|
|
|
notify:
|
|
|
|
- disable ntpd
|
|
|
|
- disable timesyncd
|
2019-04-01 23:46:15 +08:00
|
|
|
when: ntp_daemon_type == "chronyd"
|