main.yml 397 B

12345678910111213
  1. ---
  2. - name: ensure ntp and chrony are absent
  3. apt: name={{ item }} state=absent purge=yes
  4. with_items:
  5. - ntp
  6. - chrony
  7. - name: ensure systemd NTP client is enabled
  8. shell: "timedatectl | grep 'NTP enabled: yes' || timedatectl set-ntp 1"
  9. register: ntp_shell_result
  10. changed_when: "ntp_shell_result.stdout == '' and ntp_shell_result.rc == 0"
  11. failed_when: "ntp_shell_result.rc != 0"