2024-10-13 16:20:24 -04:00
|
|
|
---
|
|
|
|
- name: Configure systemd-timesyncd to use router NTP server
|
|
|
|
hosts: all
|
|
|
|
become: true
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- name: Ensure systemd-timesyncd is installed
|
|
|
|
apt:
|
|
|
|
name: systemd-timesyncd
|
|
|
|
state: present
|
|
|
|
update_cache: yes
|
|
|
|
|
2024-10-13 16:37:39 -04:00
|
|
|
- name: Configure timesyncd to use the router's NTP server using ini_file
|
|
|
|
ini_file:
|
2024-10-13 16:20:24 -04:00
|
|
|
path: /etc/systemd/timesyncd.conf
|
2024-10-13 16:37:39 -04:00
|
|
|
section: Time
|
|
|
|
option: NTP
|
|
|
|
value: '10.0.0.1'
|
2024-10-13 16:20:24 -04:00
|
|
|
|
|
|
|
- name: Restart systemd-timesyncd to apply changes
|
|
|
|
systemd:
|
|
|
|
name: systemd-timesyncd
|
|
|
|
state: restarted
|
|
|
|
enabled: yes
|
|
|
|
|
|
|
|
- name: Verify the NTP configuration
|
|
|
|
command: timedatectl status
|
|
|
|
register: timesync_status
|
|
|
|
|
|
|
|
- name: Show the status of time synchronization
|
|
|
|
debug:
|
|
|
|
msg: "{{ timesync_status.stdout }}"
|