We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ce7c0c1 commit 3ee1613Copy full SHA for 3ee1613
ansible/playbooks/ntp.yml
@@ -0,0 +1,33 @@
1
+---
2
+- name: Configure systemd-timesyncd to use router NTP server
3
+ hosts: all
4
+ become: true
5
+
6
+ tasks:
7
+ - name: Ensure systemd-timesyncd is installed
8
+ apt:
9
+ name: systemd-timesyncd
10
+ state: present
11
+ update_cache: yes
12
13
+ - name: Configure timesyncd to use the router's NTP server
14
+ lineinfile:
15
+ path: /etc/systemd/timesyncd.conf
16
+ regexp: '^NTP='
17
+ line: 'NTP=10.0.0.1'
18
+ insertafter: '^\[Time\]'
19
20
21
+ - name: Restart systemd-timesyncd to apply changes
22
+ systemd:
23
24
+ state: restarted
25
+ enabled: yes
26
27
+ - name: Verify the NTP configuration
28
+ command: timedatectl status
29
+ register: timesync_status
30
31
+ - name: Show the status of time synchronization
32
+ debug:
33
+ msg: "{{ timesync_status.stdout }}"
0 commit comments