...
If time isn't syncing, sources
will show why.
Ansible
Code Block |
---|
- name: Ensure chrony is installed
apt:
name: chrony
state: present
update_cache: yes
- name: Configure chrony to use time.aws.com
copy:
dest: /etc/chrony/chrony.conf
content: |
server time.aws.com iburst
makestep 1.0 3
log measurements statistics tracking
logdir /var/log/chrony
owner: root
group: root
mode: '0644'
- name: Set system timezone to UTC
command: timedatectl set-timezone UTC
changed_when: true
- name: Restart chrony
systemd:
name: chrony
state: restarted
enabled: yes
- name: Force chrony to step the clock
command: chronyc -a makestep
register: chrony_makestep
changed_when: >
"Can't synchronise" not in chrony_makestep.stdout
- name: Show contents of chrony.conf using cat
command: cat /etc/chrony/chrony.conf
register: chrony_config_output
changed_when: false
- name: Display config line by line
debug:
var: chrony_config_output.stdout_lines
- name: Get chrony sync status
command: chronyc tracking
register: chrony_status
changed_when: false
- name: Display chrony sync status
debug:
var: chrony_status.stdout_lines
|
...