An Ansible role that installs NTP and configures it.
- Ansible 2+
Set the system time zone. There is no default. The prefix is system_
on
purpose, so this variable can be used across different roles that also set the
time zone.
system_timezone: Europe/Berlin
NTP servers are preferred servers. They should be set to your networks internal NTP servers.
ntp_servers:
- ntp1.domain.org
- ntp2.domain.org
- ntp3.domain.org
NTP fallback servers should only be set for the above-mentioned NTP servers. Use regional pools.
ntp_fallback_servers:
- 0.europe.pool.ntp.org
- 1.europe.pool.ntp.org
- 2.europe.pool.ntp.org
- 3.europe.pool.ntp.org
If neither NTP servers nor fallback servers are specified, the default servers in the distributed configuration are used.
NTP peers are defined like this:
ntp_peers:
- ntp2.domain.org
- ntp3.domain.org
Peers will get an automatic restrict
ion, i.e. nomodify notrap
.
Optionally ease restriction on the local network, i.e. nomodify notrap nopeer
.
ntp_local_network_restriction:
net: 192.168.1.0
mask: 255.255.255.0
None.
Add to requirements.yml
:
---
- src: idiv-biodiversity.ntp
...
Download:
$ ansible-galaxy install -r requirements.yml
Write a top-level playbook:
---
- name: head server
hosts: head
roles:
- role: idiv-biodiversity.ntp
tags:
- ntp
- timesync
...
Define the role dependency in meta/main.yml
:
---
dependencies:
- role: idiv-biodiversity.ntp
tags:
- ntp
- timesync
...
With these tags, only specific parts of the role can be triggered:
timezone
: just set the time zonentp-conf
: configure/etc/ntp.conf
and restart the service if changedservice
,service-ntp
andntp-service
: enable and startntpd
; the purpose of the plainservice
tag is that you can enable and start all services across roles by using this tag, e.g.ansible-playbook site.yml -t service
The tags from the Example Playbook are ntp
and
timesync
. In case you switch from different time synchronization roles, the
timesync
tag should come in handy, in case these roles also use this tag.
MIT
This role was created in 2017 by Christian Krause aka wookietreiber at GitHub, HPC cluster systems administrator at the German Centre for Integrative Biodiversity Research (iDiv).