File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change
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
+ state : present
20
+
21
+ - name : Restart systemd-timesyncd to apply changes
22
+ systemd :
23
+ name : systemd-timesyncd
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 }}"
You can’t perform that action at this time.
0 commit comments