---
- name: Configure Chrony clients
hosts: linux_clients
become: yes
vars:
ntp_server: 192.168.1.10
tasks:
- name: Install chrony
apt:
name: chrony
state: present
update_cache: yes
- name: Remove default pool/server lines
replace:
path: /etc/chrony/chrony.conf
regexp: '^(pool|server)\s+.*'
replace: ''
- name: Add local NTP server
lineinfile:
path: /etc/chrony/chrony.conf
line: "server {{ ntp_server }} iburst"
insertafter: EOF
- name: Enable and restart chrony
systemd:
name: chrony
enabled: yes
state: restarted