roles_timesync/roles/timesync-disabled/tasks/main.yml

39 lines
929 B
YAML
Raw Normal View History

2017-11-30 14:28:28 +00:00
---
- name: Deinstall NTProtocol package(s)
package:
2020-12-03 13:49:33 +00:00
name: "{{ timesync_packages_deinstall }}"
2017-11-30 14:28:28 +00:00
state: absent
- name: Look for /usr/bin/timedatectl command
stat:
path: /usr/bin/timedatectl
register: timedatectlcommand
2020-12-03 13:49:33 +00:00
- name: Only with timedatectl
block:
2017-11-30 14:28:28 +00:00
- name: See if timesyncd is active
2020-12-03 13:49:33 +00:00
shell: 'timedatectl | grep "\(NTP service\|NTP enabled\|Network time on\):" | cut -d: -f 2 | grep -o "active\|inactive\|yes\|no\|n/a"'
2017-11-30 14:28:28 +00:00
changed_when: False
ignore_errors: True
register: timedatectl
- name: Disable timesyncd-NTProtocol
command: timedatectl set-ntp false
2020-12-03 13:49:33 +00:00
when: timedatectl is success and timedatectl.stdout in ["active", "yes"]
2017-11-30 14:28:28 +00:00
- name: Stop/Disable timesyncd service
service:
name: systemd-timesyncd
enabled: False
state: stopped
2020-12-03 13:49:33 +00:00
when: timedatectl is success and timedatectl.stdout != "n/a"
2017-11-30 14:28:28 +00:00
when: timedatectlcommand.stat.exists == True