-
-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consolidate templates and convert to epp() #79
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't use chrony myself so can't comment that much. Just small things that jumped out to me
manifests/params.pp
Outdated
@@ -6,7 +6,7 @@ | |||
'Archlinux' : { | |||
$cmdacl = ['cmdallow 127.0.0.1'] | |||
$config = '/etc/chrony.conf' | |||
$config_template = 'chrony/chrony.conf.archlinux.erb' | |||
$config_template = 'chrony/chrony.conf.epp' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is now the same everywhere, you can move it to init.pp
as a static value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes absolutely, but I think it should have it's own commit, and a separate PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree. init.pp already has all static values and params.pp only has values that differ for various OSes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I see your point I have added a commit to do this.
Replace the separate erb-templates for chrony.conf with one epp-template. The chrony.conf.epp is based on the erb-template for redhat.
Fix typo cut&paste typo Co-authored-by: Ewoud Kohl van Wijngaarden <[email protected]>
Since this now has the same value for all OS, this don't need to be set by params.pp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From a Puppet code perspective this looks ok. I don't use chrony so I can't comment too much on anything you may have missed.
Any chrony user can take a look?
templates/chrony.conf.epp
Outdated
bindcmdaddress <%= $addr %> | ||
<% } -%> | ||
<% } -%> | ||
<% if ! $chrony::cmdacl.empty { -%> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically this isn't needed. It's guaranteed to be an array and you can iterate 0 times over an empty array. In other cases it makes sense for whitespace control but that doesn't happen here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right again. And you also guessed correctly that my reason for several of the if-statements is to limit empty blank lines in the file.
And also decrease nr of empty lines added to configfile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, this will make the maintenance easier
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
# NTP servers | ||
<% $chrony::servers.each |$server| { -%> | ||
server <%= $server.flatten.join(' ') %> | ||
<% } -%> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not good enough when $chrony::servers is a hash. It (kind of) works, because
.each() returns a Array ['key','value']. But if I use hieradata with a hash without value,
this will result in a line ending with a space.
Example:
chrony::servers:
ntp1.example.com:
- minpoll 3
- maxpoll 7
ntp2.example.com:
It results in server "ntp1.example.com minpoll 3 maxpoll 7", but "server ntp2.example.com "
I'm going to think some about this, and submit a PR with a fix later. We should also have
a test that would have detected this.
The conversion from ERB to EPP in voxpupuli#79 changed the behavior of queryhosts slightly. Before, setting queryhosts to the empty string worked for configuring chrony to allow any query. After, empty string is considered empty, so the "allow" directive would not be rendered. Enforcing the data type ensures that people upgrading this module who have been using empty string get an error rather than a valid but misconfigured chrony.conf. The replacement for empty string is an array with a single empty string element: ['']
The conversion from ERB to EPP in voxpupuli#79 changed the behavior of queryhosts slightly. Before, setting queryhosts to the empty string worked for configuring chrony to allow any query. After, empty string is considered empty, so the "allow" directive would not be rendered. Enforcing the data type ensures that people upgrading this module who have been using empty string get an error rather than a valid but misconfigured chrony.conf. The replacement for empty string is an array with a single empty string element: ['']
The conversion from ERB to EPP in #79 changed the behavior of queryhosts slightly. Before, setting queryhosts to the empty string worked for configuring chrony to allow any query. After, empty string is considered empty, so the "allow" directive would not be rendered. Enforcing the data type ensures that people upgrading this module who have been using empty string get an error rather than a valid but misconfigured chrony.conf. The replacement for empty string is an array with a single empty string element: ['']
@@ -0,0 +1,122 @@ | |||
# NTP servers | |||
<% $chrony::servers.each |$server| { -%> | |||
server <%= $server.flatten.join(' ') %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If $chrony::servers
is an array, this is broken.
Error: Error while evaluating a Method call, flatten(): Requires array to work with
Also the old behavior was to use iburst
<% if @servers.is_a?(Hash) then @servers.keys.sort.each do |server| -%>
server <%= server %> <%= @servers[server].join(' ') %>
<% end else Array(@servers).each do |server| -%>
server <%= server %> iburst
<% end end -%>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually... it might just be a problem because I was testing against a puppet 4 system... :(
Prior to puppet 5.5, flatten
comes from stdlib.
Before the conversion to epp in voxpupuli#79, an array of servers/pools would get the `iburst` option set for each server/pool. This restores the old behaviour and gets rid of the `flatten` magic at the expense of several extra lines of template.
Before the conversion to epp in voxpupuli#79, an array of servers/pools would get the `iburst` option set for each server/pool. This restores the old behaviour and gets rid of the `flatten` magic at the expense of several extra lines of template.
Before the conversion to epp in voxpupuli#79, an array of servers/pools would get the `iburst` option set for each server/pool. This restores the old behaviour and gets rid of the `flatten` magic at the expense of several extra lines of template.
Before the conversion to epp in voxpupuli#79, an array of servers/pools would get the `iburst` option set for each server/pool. This restores the old behaviour and gets rid of the `flatten` magic at the expense of several extra lines of template.
Before the conversion to epp in voxpupuli#79, an array of servers/pools would get the `iburst` option set for each server/pool. This restores the old behaviour and gets rid of the `flatten` magic at the expense of several extra lines of template.
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 voxpupuli#141 and voxpupuli#79. Rather than restore the full variations that were supported in voxpupuli#79 a simplified hash structure was chosen. Fixes voxpupuli#189 Signed-off-by: Ben Magistro <[email protected]>
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 voxpupuli#141 and voxpupuli#79. Rather than restore the full variations that were supported prior to voxpupuli#79 a simplified hash structure was chosen. Fixes voxpupuli#189 Signed-off-by: Ben Magistro <[email protected]>
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 voxpupuli#141 and voxpupuli#79. Rather than restore the full variations that were supported prior to voxpupuli#79 a simplified hash structure was chosen. Fixes voxpupuli#189 Signed-off-by: Ben Magistro <[email protected]>
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 voxpupuli#141 and voxpupuli#79. Rather than restore the full variations that were supported prior to voxpupuli#79 a simplified hash structure was chosen. Fixes voxpupuli#189 Signed-off-by: Ben Magistro <[email protected]>
Replace the separate erb-templates for chrony.conf with one epp-template.
The chrony.conf.epp is based on the erb-template for redhat.