--- - name: See if NTProtocol active shell: 'timedatectl | grep "NTP synchronized:" | cut -d: -f 2 | grep -o "yes\|no"' register: timedatectl - name: Template configuration template: src: etc/systemd/timesyncd.conf.j2 dest: /etc/systemd/timesyncd.conf notify: Restart systemd-timesyncd - name: Activate NTProtocol command: timedatectl set-ntp true when: timedatectl.stdout == "no" - name: Enable service service: name: systemd-timesyncd enabled: True