time.yml 540 B

1234567891011121314
  1. ---
  2. # libpam-systemd and dbus (dependency) are needed for timedatectl to work
  3. - name: ensure libpam-systemd is installed
  4. apt: name=libpam-systemd install_recommends=no
  5. - name: ensure timezone is set to CET
  6. command: timedatectl set-timezone CET
  7. when: ansible_date_time.tz != "CET"
  8. - name: ensure NTP is enabled
  9. shell: "timedatectl | grep 'NTP enabled: yes' || timedatectl set-ntp 1"
  10. register: ntp_shell_result
  11. changed_when: "ntp_shell_result.stdout == '' and ntp_shell_result.rc == 0"
  12. failed_when: "ntp_shell_result.rc != 0"