diff --git a/ntpd/manifests/init.pp b/ntpd/manifests/init.pp index 0b67598..3848cc8 100644 --- a/ntpd/manifests/init.pp +++ b/ntpd/manifests/init.pp @@ -11,13 +11,42 @@ class ntpd { $ntp_server = ["pool.ntp.org"] } - case $kernel { - linux: { - include ntpd::isc-ntpd + case $operatingsystem { + "fedora": { + include ntpd::chrony } - openbsd: { + "openbsd": { include ntpd::openntpd } + default: { + include ntpd::isc-ntpd + } + } + +} + + +# Install and configure Chrony NTP client. +# +class ntpd::chrony { + + package { "chrony": + ensure => installed, + } + + file { "/etc/chrony.conf": + ensure => present, + mode => 0644, + owner => "root", + group => "root", + content => template("ntpd/chrony.conf.erb"), + require => Package["chrony"], + notify => Service["chronyd"], + } + + service { "chronyd": + ensure => running, + enable => true, } } diff --git a/ntpd/templates/chrony.conf.erb b/ntpd/templates/chrony.conf.erb new file mode 100644 index 0000000..0c3b75c --- /dev/null +++ b/ntpd/templates/chrony.conf.erb @@ -0,0 +1,38 @@ +# Remote servers. +<% ntp_server.each do |server| -%> +server <%= server %> iburst +<% end -%> + +# Ignore stratum in source selection. +stratumweight 0 + +# Record the rate at which the system clock gains/losses time. +driftfile /var/lib/chrony/drift + +# Enable kernel RTC synchronization. +rtcsync + +# In first three updates step the system clock instead of slew +# if the adjustment is larger than 100 seconds. +makestep 100 3 + +# Allow client access from local network. +#allow 192.168/16 + +# Serve time even if not synchronized to any NTP server. +#local stratum 10 + +keyfile /etc/chrony.keys + +# Specify the key used as password for chronyc. +commandkey 1 + +# Disable logging of client accesses. +noclientlog + +# Send a message to syslog if a clock adjustment is larger than 0.5 seconds. +logchange 0.5 + +logdir /var/log/chrony +#log measurements statistics tracking +