# sudo bash -c 'ansible-playbook <(curl -s https://gist.githubusercontent.com/mschmitt/0895da5e328775858b21bf4e5cc8d56c/raw/play-ntp.yml)' --- - hosts: localhost gather_facts: true connection: local tasks: - name: Disable systemd-timesyncd systemd_service: name: systemd-timesyncd state: stopped enabled: false - name: Install ntp (Arch) package: name: ntp state: present when: ansible_facts['os_family'] == 'Archlinux' - name: Install ntpsec and ntpdate (Debian) package: name: - ntpsec - ntpsec-ntpdate state: present when: ansible_facts['os_family'] == 'Debian' - name: Ensure ntpd is stopped systemd_service: name: ntpd state: stopped - name: Acquire time command: ntpdate pool.ntp.org - name: Start and enable ntpdate (Arch) systemd_service: name: ntpd state: started enabled: true when: ansible_facts['os_family'] == 'Archlinux' - name: Start and enable ntpd systemd_service: name: ntpd state: started enabled: true # vim: filetype=yaml