Skip to content

Commit 3ee1613

Browse files
committedOct 13, 2024
add ntp playbook
1 parent ce7c0c1 commit 3ee1613

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
 

‎ansible/playbooks/ntp.yml

+33
Original file line numberDiff line numberDiff line change
@@ -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+
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 }}"

0 commit comments

Comments
 (0)
Please sign in to comment.