timesync_timesyncd.yml 489 B

123456789101112131415161718192021222324
  1. ---
  2. - name: See if NTProtocol active
  3. shell: 'timedatectl | grep "NTP synchronized:" | cut -d: -f 2 | grep -o "yes\|no"'
  4. register: timedatectl
  5. - name: Template configuration
  6. template:
  7. src: etc/systemd/timesyncd.conf.j2
  8. dest: /etc/systemd/timesyncd.conf
  9. notify: Restart systemd-timesyncd
  10. - name: Activate NTProtocol
  11. command: timedatectl set-ntp true
  12. when: timedatectl.stdout == "no"
  13. - name: Enable service
  14. service:
  15. name: systemd-timesyncd
  16. enabled: True