From cbd11ab12bb0a97b73f13f408e54b9ce82661035 Mon Sep 17 00:00:00 2001 From: Sven Velt Date: Thu, 3 Dec 2020 14:48:53 +0100 Subject: [PATCH] Make timedatectl calls more robust --- roles/timesync-enabled/tasks/timesync_timesyncd.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/roles/timesync-enabled/tasks/timesync_timesyncd.yml b/roles/timesync-enabled/tasks/timesync_timesyncd.yml index e322fe0..f7ed762 100644 --- a/roles/timesync-enabled/tasks/timesync_timesyncd.yml +++ b/roles/timesync-enabled/tasks/timesync_timesyncd.yml @@ -1,9 +1,16 @@ --- - name: See if NTProtocol active - shell: 'timedatectl | grep "NTP synchronized:" | cut -d: -f 2 | grep -o "yes\|no"' + shell: 'timedatectl | grep "\(NTP service\|NTP enabled\|Network time on\):" | cut -d: -f 2 | grep -o "active\|inactive\|yes\|no\|n/a"' + ignore_errors: True register: timedatectl +- name: 'Fail if "timedatectl" could not be executed"' + fail: + msg: 'Could not execute "timedatectl", give up....' + when: timedatectl is failed + + - name: Template configuration template: src: etc/systemd/timesyncd.conf.j2