- hosts: all become: yes tasks: - name: check if ntp is installed apt: pkg: - ntp state: present update_cache: no force_apt_get: True register: ntp - name: set hw clock to UTC from host command: hwclock --set --date "{{ lookup('pipe','date -u') }}" when: ntp.failed - name: Set timezone to Europe/Berlin timezone: name: Europe/Berlin hwclock: UTC register: tz - name: Unconditionally reboot the machine to apply tz change reboot: when: tz.changed - name: install ntp apt: pkg: - ntp state: present update_cache: yes force_apt_get: True when: ntp.failed - name: Make sure NTP is started up service: name=ntp state=started enabled=yes