hafu.systemd_timesyncd
systemd-timesyncd
This configuration sets up the systemd-timesyncd service. You can also remove other NTP services like chrony, ntp, or openntpd, and/or set the timezone.
Requirements
You need a system that has systemd with timesyncd.
Role Variables
Default settings can be found in defaults/main.yml
, and operating system-specific variables are in vars/
.
systemd_timesycd_remove_other_daemons: false
systemd_timesycd_other_daemons: []
By default, no other NTP daemons are removed. If you wish to remove them, set systemd_timesycd_remove_other_daemons
to true
. The list of packages to be removed is defined in the playbook via the YAML file in the vars
directory.
systemd_timesycd_set_timezone: false
systemd_timesycd_timezone: Etc/UTC
Setting the timezone is also turned off by default. To set it, change systemd_timesycd_set_timezone
to true
and specify the timezone with systemd_timesycd_timezone
.
systemd_timesycd_conf_ntp_servers: []
systemd_timesycd_conf_fallback_ntp:
- 0.pool.ntp.org
- 1.pool.ntp.org
- 2.pool.ntp.org
- 3.pool.ntp.org
The systemd_timesycd_conf_ntp_servers
variable should include a list of NTP servers. This sets the NTP=
option in timesyncd.conf. The systemd-networkd service can combine this list with other servers it finds.
If no servers are provided in systemd_timesycd_conf_ntp_servers
, the servers in systemd_timesycd_conf_fallback_ntp
will be used as a backup. This is like the FallbackNTP=
option in timesyncd.conf.
systemd_timesycd_conf_root_distance_max_sec: 5
systemd_timesycd_conf_poll_interval_min_sec: 32
systemd_timesycd_conf_poll_interval_max_sec: 2048
These are optional settings:
systemd_timesycd_conf_root_distance_max_sec
->RootDistanceMaxSec
systemd_timesycd_conf_poll_interval_min_sec
->PollIntervalMinSec
systemd_timesycd_conf_poll_interval_max_sec
->PollIntervalMaxSec
For more information, see timesyncd.conf.
Dependencies
No additional dependencies.
Example Playbook
This example removes other NTP daemons, sets the timezone to Europe/Berlin
, and uses German NTP servers.
- hosts: servers
roles:
- role: hafu.systemd-timesyncd
systemd_timesycd_remove_other_daemons: true
systemd_timesycd_set_timezone: true
systemd_timesycd_timezone: Europe/Berlin
systemd_timesycd_conf_fallback_ntp:
- 0.de.pool.ntp.org
- 1.de.pool.ntp.org
- 2.de.pool.ntp.org
- 3.de.pool.ntp.org
License
MIT
Author Information
Setup systemd-timesyncd. Optionally sets timezone and removes other NTP daemons.
ansible-galaxy install hafu.systemd_timesyncd