diff --git a/roles/timesync-disabled/defaults/main.yml b/roles/timesync-disabled/defaults/main.yml new file mode 100644 index 0000000..48b98da --- /dev/null +++ b/roles/timesync-disabled/defaults/main.yml @@ -0,0 +1,8 @@ +--- +timesync_packages_deinstall: + - ntp + - ntpd + - chrony + - openntpd + - radioclk + diff --git a/roles/timesync-disabled/tasks/main.yml b/roles/timesync-disabled/tasks/main.yml index 07c17f4..8e31868 100644 --- a/roles/timesync-disabled/tasks/main.yml +++ b/roles/timesync-disabled/tasks/main.yml @@ -1,14 +1,8 @@ --- - name: Deinstall NTProtocol package(s) package: - name: "{{ item }}" + name: "{{ timesync_packages_deinstall }}" state: absent - with_items: - - ntp - - ntpd - - chrony - - openntpd - - radioclk - name: Look for /usr/bin/timedatectl command @@ -17,10 +11,11 @@ register: timedatectlcommand -- block: +- name: Only with timedatectl + block: - name: See if timesyncd is active - shell: 'timedatectl | grep "\(NTP enabled\|Network time on\):" | cut -d: -f 2 | grep -o "yes\|no\|n/a"' + shell: 'timedatectl | grep "\(NTP service\|NTP enabled\|Network time on\):" | cut -d: -f 2 | grep -o "active\|inactive\|yes\|no\|n/a"' changed_when: False ignore_errors: True register: timedatectl @@ -28,7 +23,7 @@ - name: Disable timesyncd-NTProtocol command: timedatectl set-ntp false - when: timedatectl|success and timedatectl.stdout == "yes" + when: timedatectl is success and timedatectl.stdout in ["active", "yes"] - name: Stop/Disable timesyncd service @@ -36,7 +31,7 @@ name: systemd-timesyncd enabled: False state: stopped - when: timedatectl|success and timedatectl.stdout != "n/a" + when: timedatectl is success and timedatectl.stdout != "n/a" when: timedatectlcommand.stat.exists == True