Homelab-Infra/roles/base_os/tasks/time_sync.yml

29 lines
779 B
YAML

---
#base_os/tasks/time_sync.yml
- name: Chrony time sync (dev only)
when: env == "test"
block:
- name: Ensure chronyd is running
become: true
ansible.builtin.service:
name: chronyd
state: started
enabled: true
- name: Wait for chrony to have reachable sources
become: true
command: chronyc activity
register: chrony_activity
retries: 20
delay: 2
until: "'sources online' in chrony_activity.stdout and '0 sources online' not in chrony_activity.stdout"
- name: Force time step correction
become: true
command: chronyc -a makestep
- name: Verify system time is reasonable
command: date
register: date_check
failed_when: "'2026-04-13' in date_check.stdout"