blob: c6a9bd2a076b5e3456dcf7ec4ad0f194ed252ea9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
---
- block:
- name: Check for a running host NTP daemon # noqa command-instead-of-module
vars:
prechecks_host_ntp_daemons:
- chrony
- chronyd
- ntp
- ntpd
- systemd-timesyncd
become: true
command:
cmd: "systemctl is-active {{ prechecks_host_ntp_daemons | join(' ') }}"
register: systemctl_is_active
changed_when: false
failed_when: false
check_mode: false
- name: Fail if a host NTP daemon is not running
fail:
msg: >-
No host NTP daemon is running.
Please install and configure a host NTP daemon.
Alternatively, set 'prechecks_enable_host_ntp_checks' to 'false' to
disable this check if not using one of the following NTP daemons:
chrony, ntpd, systemd-timesyncd.
when:
- systemctl_is_active.rc != 0
- name: Checking timedatectl status
become: true
command: timedatectl status
register: timedatectl_status
changed_when: false
check_mode: false
- name: Fail if the clock is not synchronized
fail:
msg: >-
timedatectl sees the system clock as unsynchronized.
Please wait for synchronization.
Alternatively, set 'prechecks_enable_host_ntp_checks' to 'false' to
disable this check if your NTP daemon is not recognised by
'timedatectl status'.
when:
- "'synchronized: yes' not in timedatectl_status.stdout"
when: prechecks_enable_host_ntp_checks | bool
|