diff --git a/roles/common/handlers/main.yaml b/roles/common/handlers/main.yaml index 54d1471..3a98051 100644 --- a/roles/common/handlers/main.yaml +++ b/roles/common/handlers/main.yaml @@ -4,3 +4,9 @@ name: sshd state: restarted become: true + +- name: Restart timesyncd + ansible.builtin.systemd: + name: systemd-timesyncd + state: restarted + become: true diff --git a/roles/common/tasks/time.yaml b/roles/common/tasks/time.yaml index 0b03106..41346a0 100644 --- a/roles/common/tasks/time.yaml +++ b/roles/common/tasks/time.yaml @@ -10,6 +10,14 @@ name: "{{ timezone }}" when: ansible_user_id == "root" +- name: Configure NTP servers for systemd-timesyncd + ansible.builtin.lineinfile: + path: /etc/systemd/timesyncd.conf + regexp: "^#?NTP=" + line: "NTP=0.debian.pool.ntp.org 1.debian.pool.ntp.org 2.debian.pool.ntp.org 3.debian.pool.ntp.org" + become: true + notify: Restart timesyncd + - name: Enable and start systemd-timesyncd ansible.builtin.systemd: name: systemd-timesyncd