This ansible role can configure chrony OR ntp for clock synchronization.
it allow an easy switch between chrony, timesync, and ntpd.
| Platform | Versions |
|---|---|
| Debian | all |
| EL | all |
| Fedora | all |
| Ubuntu | all |
Ansible >= 2.13
None.
ansible-galaxy install dginhoux.ntp_syncgit clone https://github.com/dginhoux/ansible_role.ntp_sync dginhoux.ntp_sync- name:
hosts: all
tasks:
- name: Start role dginhoux.ntp_sync
ansible.builtin.include_role:
name: dginhoux.ntp_syncDefaults variables defined in defaults/main.yml
ntp_enabled: true
ntp_install_package: true
ntp_remove_package: true
ntp_install_tzdata: true
ntp_manage_config: true
ntp_manage_services: true
ntp_daemon_choice: ntp
# ntp_daemon_choice: chrony
# ntp_daemon_choice: timesyncd
ntp_timezone: Europe/Paris
ntp_servers:
- "ntp1.infra.ginhoux.net"
- "ntp2.infra.ginhoux.net"
- "ntp3.infra.ginhoux.net"
ntp_pools:
- "0.fr.pool.ntp.org"
- "1.fr.pool.ntp.org"
- "2.fr.pool.ntp.org"
- "3.fr.pool.ntp.org"
ntp_chrony_allow:
- "127.0.0.1/32"
- "192.168.0.0/16"
ntp_ntpd_tinker_panic: false
ntp_ntpd_restrict:
- "127.0.0.1 nomodify"
- "-4 default kod notrap nomodify nopeer noquery"
- "-6 default kod notrap nomodify nopeer noquery"
- "192.168.0.0 mask 255.255.0.0 nomodify notrap"Those variables files are located in vars/*.yml are used to handle OS differences.
One of theses is loaded dynamically during role runtime using the include_vars module and set OS specifics variable's.
- RedHat Family
ntp_daemon_conf:
ntp:
ntp_daemon_install_package:
- ntpsec
ntp_daemon_remove_package:
- chrony
ntp_daemon_enable_service:
- ntp
ntp_daemon_disable_service:
- chronyd
- systemd-timesyncd
ntp_daemon_config_file: /etc/ntp.conf
chrony:
ntp_daemon_install_package:
- chrony
ntp_daemon_remove_package:
- ntp
ntp_daemon_enable_service:
- chronyd
ntp_daemon_disable_service:
- ntp
- systemd-timesyncd
ntp_daemon_config_file: /etc/chrony/chrony.conf
timesyncd:
ntp_daemon_install_package: []
ntp_daemon_remove_package:
- chrony
- ntp
ntp_daemon_enable_service:
- systemd-timesyncd
ntp_daemon_disable_service:
- chronyd
- ntp
ntp_daemon_config_file: /etc/systemd/timesyncd.conf
ntp_tzdata_package:
- tzdata
ntp_timezone_file: /etc/sysconfig/clock
ntp_chrony_driftfile: /var/lib/chrony/drift
ntp_chrony_keyfile: /etc/chrony.keys
ntp_chrony_confdir: /etc/chrony
ntp_chrony_logdir: /var/log/chrony
ntp_chrony_envfile: /etc/sysconfig/chronyd
ntp_ntpd_driftfile: /var/lib/ntp/drift- Debian Family
ntp_daemon_conf:
ntp:
ntp_daemon_install_package:
- ntp
ntp_daemon_remove_package:
- chrony
ntp_daemon_enable_service:
- ntp
ntp_daemon_disable_service:
- chronyd
- systemd-timesyncd
ntp_daemon_config_file: /etc/ntp.conf
chrony:
ntp_daemon_install_package:
- chrony
ntp_daemon_remove_package:
- ntp
ntp_daemon_enable_service:
- chronyd
ntp_daemon_disable_service:
- ntp
- systemd-timesyncd
ntp_daemon_config_file: /etc/chrony/chrony.conf
timesyncd:
ntp_daemon_install_package: []
ntp_daemon_remove_package:
- chrony
- ntp
ntp_daemon_enable_service:
- systemd-timesyncd
ntp_daemon_disable_service:
- chronyd
- ntp
ntp_daemon_config_file: /etc/systemd/timesyncd.conf
ntp_tzdata_package:
- tzdata
ntp_timezone_file: /etc/timezone
ntp_chrony_driftfile: /var/lib/chrony/chrony.drift
ntp_chrony_keyfile: /etc/chrony/chrony.keys
ntp_chrony_confdir: /etc/chrony
ntp_chrony_logdir: /var/log/chrony
ntp_chrony_envfile: /etc/default/chrony
ntp_ntpd_driftfile: /var/lib/ntp/driftDany GINHOUX - https://github.com/dginhoux
MIT