From ac8ed0feff276ad745f5adb62fe21d73346212d8 Mon Sep 17 00:00:00 2001 From: Ben Magistro Date: Thu, 4 Jan 2024 15:39:59 +0000 Subject: [PATCH] fix refclock generation This updates the refclock parameter data types to be a hash which matches the examples and updates the template to properly generate multiple refclock entries. This looks to have broken via a combination of #141 and #79. Rather than restore the full variations that were supported prior to #79 a simplified hash structure was chosen. Fixes #189 Signed-off-by: Ben Magistro --- REFERENCE.md | 9 ++++----- manifests/init.pp | 7 +++---- templates/chrony.conf.epp | 6 ++++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/REFERENCE.md b/REFERENCE.md index b6cea39..9b12874 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -507,20 +507,19 @@ Default value: `undef` ##### `refclocks` -Data type: `Array` +Data type: `Hash` This should be a Hash of hardware reference clock drivers to use. They hash -can either list a single list of options for the driver, or any array of -multiple options if the same driver is used for multiple hardware clocks. +should be an array of hardware clocks and their options for that driver. Example: ```puppet refclocks => { 'PPS' => [ '/dev/pps0 lock NMEA refid GPS', '/dev/pps1:clear refid GPS2' ], - 'SHM' => '0 offset 0.5 delay 0.2 refid NMEA noselect' } + 'SHM' => [ '0 offset 0.5 delay 0.2 refid NMEA noselect' ] } ``` -Default value: `[]` +Default value: `{}` ##### `makestep_seconds` diff --git a/manifests/init.pp b/manifests/init.pp index d024d8d..31bd7dd 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -146,14 +146,13 @@ # Specifies the minimum number of readings kept for tracking of the NIC clock. # @param refclocks # This should be a Hash of hardware reference clock drivers to use. They hash -# can either list a single list of options for the driver, or any array of -# multiple options if the same driver is used for multiple hardware clocks. +# should be an array of hardware clocks and their options for that driver. # # Example: # ```puppet # refclocks => { 'PPS' => [ '/dev/pps0 lock NMEA refid GPS', # '/dev/pps1:clear refid GPS2' ], -# 'SHM' => '0 offset 0.5 delay 0.2 refid NMEA noselect' } +# 'SHM' => [ '0 offset 0.5 delay 0.2 refid NMEA noselect' ] } # ``` # @param makestep_seconds # Configures the [`makestep`](https://chrony.tuxfamily.org/doc/3.4/chrony.conf.html#makestep) `threshold`. @@ -275,7 +274,7 @@ String[1] $package_name = 'chrony', Optional[String] $package_source = undef, Optional[String] $package_provider = undef, - Array $refclocks = [], + Hash $refclocks = {}, Chrony::Servers $peers = [], Chrony::Servers $servers = { '0.pool.ntp.org' => ['iburst'], diff --git a/templates/chrony.conf.epp b/templates/chrony.conf.epp index ed114c8..f562505 100644 --- a/templates/chrony.conf.epp +++ b/templates/chrony.conf.epp @@ -157,8 +157,10 @@ log <%= $chrony::log_options %> <% } -%> <% unless $chrony::refclocks.empty { -%> -<% $chrony::refclocks.each |$driver| { -%> -refclock <%= $driver.flatten.join(' ') %> +<% $chrony::refclocks.each |$driver, $clocks| { -%> +<% $clocks.each |$clock| { -%> +refclock <%= $driver %> <%= $clock %> +<% } -%> <% } -%> <% } -%> <% if $chrony::lock_all { -%>