From 159eed6536f93f7fa1b442efbf5d15973fa375e1 Mon Sep 17 00:00:00 2001 From: John Warburton Date: Thu, 27 Sep 2018 11:27:47 +1000 Subject: [PATCH] support for peers, variable local stratum, SUSE 12 --- README.md | 13 ++++++++++++- manifests/config.pp | 1 + manifests/init.pp | 2 ++ manifests/params.pp | 4 +++- templates/chrony.conf.debian.erb | 6 +++++- templates/chrony.conf.redhat.erb | 6 +++++- 6 files changed, 28 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0521a66..b3c922b 100644 --- a/README.md +++ b/README.md @@ -159,6 +159,11 @@ This determines which template puppet should use for the chrony key file. An array of key lines. These are printed as-is into the chrony key file. +#### `local_stratum` + +Override the stratum of the server which will be reported to clients +when the local reference is active. Defaults to 10 + #### `log_options` Specify which information is to be logged. @@ -172,9 +177,14 @@ chrony package to be installed. This determines the name of the package to install. +#### `peers` + +This selects the servers to use for NTP peers (symmetric association). +It is an array of servers. + #### `servers` -This selects the servers to use for ntp peers. It can be an array of servers +This selects the servers to use for NTP servers. It can be an array of servers or a hash of servers to their respective options. #### `makestep_updates`, `makestep_seconds` @@ -229,3 +239,4 @@ The module has been tested on: * Arch Linux * Red Hat * Debian (9) + * Suse 12.3 diff --git a/manifests/config.pp b/manifests/config.pp index 3dc48eb..15041c0 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -15,6 +15,7 @@ $mailonchange = $chrony::mailonchange, $threshold = $chrony::threshold, $lock_all = $chrony::lock_all, + $peers = $chrony::peers, $servers = $chrony::servers,) inherits chrony { file { $config: ensure => file, diff --git a/manifests/init.pp b/manifests/init.pp index 49664c4..693eadc 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -10,10 +10,12 @@ $config_keys_mode = $chrony::params::config_keys_mode, $config_keys_manage = $chrony::params::config_keys_manage, $keys = $chrony::params::keys, + $local_stratum = $chrony::params::local_stratum, $log_options = $chrony::params::log_options, $package_ensure = $chrony::params::package_ensure, $package_name = $chrony::params::package_name, $refclocks = $chrony::params::refclocks, + $peers = $chrony::params::peers, $servers = $chrony::params::servers, $makestep_seconds = $chrony::params::makestep_seconds, $makestep_updates = $chrony::params::makestep_updates, diff --git a/manifests/params.pp b/manifests/params.pp index 514e28c..e001456 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -4,11 +4,13 @@ $log_options = undef $package_ensure = 'present' $refclocks = [] + $peers = [] $service_enable = true $service_ensure = 'running' $service_manage = true $chrony_password = 'xyzzy' $queryhosts = [] + $local_stratum = 10 $port = 0 $config_keys_manage = true $mailonchange = undef @@ -27,7 +29,7 @@ $service_name = 'chrony' $clientlog = true } - 'RedHat' : { + 'Suse', 'RedHat' : { $config = '/etc/chrony.conf' $config_template = 'chrony/chrony.conf.redhat.erb' $config_keys = '/etc/chrony.keys' diff --git a/templates/chrony.conf.debian.erb b/templates/chrony.conf.debian.erb index 259e032..57a9711 100644 --- a/templates/chrony.conf.debian.erb +++ b/templates/chrony.conf.debian.erb @@ -6,6 +6,10 @@ server <%= server %> <%= @servers[server].join(' ') %> server <%= server %> iburst <% end end -%> +<% Array(@peers).each do |peer| -%> +peer <%= peer %> +<% end -%> + # Ignore stratum in source selection. stratumweight 0 @@ -33,7 +37,7 @@ bindcmdaddress ::1 port <%= @port %> # Serve time even if not synchronized to any NTP server. -local stratum 10 +local stratum <%= @local_stratum %> keyfile <%= @config_keys %> diff --git a/templates/chrony.conf.redhat.erb b/templates/chrony.conf.redhat.erb index 259e032..57a9711 100644 --- a/templates/chrony.conf.redhat.erb +++ b/templates/chrony.conf.redhat.erb @@ -6,6 +6,10 @@ server <%= server %> <%= @servers[server].join(' ') %> server <%= server %> iburst <% end end -%> +<% Array(@peers).each do |peer| -%> +peer <%= peer %> +<% end -%> + # Ignore stratum in source selection. stratumweight 0 @@ -33,7 +37,7 @@ bindcmdaddress ::1 port <%= @port %> # Serve time even if not synchronized to any NTP server. -local stratum 10 +local stratum <%= @local_stratum %> keyfile <%= @config_keys %>