diff --git a/roles/common/tasks/ntp.yml b/roles/common/tasks/ntp.yml index 587df2e..8035c9d 100644 --- a/roles/common/tasks/ntp.yml +++ b/roles/common/tasks/ntp.yml @@ -8,6 +8,14 @@ command: /usr/bin/timedatectl set-timezone {{ timezone }} tags: timezone +# Apparently some cloud images don't have this installed by default. From what +# I can see on existing servers, systemd-timesyncd is a standalone package on +# Ubuntu 20.04 and Debian 11. +- name: Install systemd-timesyncd + when: (ansible_distribution == 'Ubuntu' and ansible_distribution_version is version('20.04', '==')) or + (ansible_distribution == 'Debian' and ansible_distribution_version is version('11', '==')) + apt: name=systemd-timesyncd state=present cache_valid_time=3600 + - name: Start and enable systemd's NTP client when: ansible_service_mgr == 'systemd' systemd: name=systemd-timesyncd state=started enabled=yes