--- - name: ensure ntp and chrony are absent apt: name={{ item }} state=absent purge=yes with_items: - ntp - chrony - name: ensure systemd NTP client is enabled shell: "timedatectl | grep 'NTP enabled: yes' || timedatectl set-ntp 1" register: ntp_shell_result changed_when: "ntp_shell_result.stdout == '' and ntp_shell_result.rc == 0" failed_when: "ntp_shell_result.rc != 0"