Skip to content
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

Merged
merged 4 commits into from
Jul 10, 2020
Merged

Conversation

chrekh
Copy link
Contributor

@chrekh chrekh commented Jul 9, 2020

Replace the separate erb-templates for chrony.conf with one epp-template.
The chrony.conf.epp is based on the erb-template for redhat.

This was referenced Jul 9, 2020
Copy link
Member

@ekohl ekohl left a 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

@@ -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'
Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Member

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.

Copy link
Contributor Author

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.

templates/chrony.conf.epp Outdated Show resolved Hide resolved
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]>
@ekohl ekohl linked an issue Jul 9, 2020 that may be closed by this pull request
Since this now has the same value for all OS, this don't need to be set by params.pp
Copy link
Member

@ekohl ekohl left a 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?

bindcmdaddress <%= $addr %>
<% } -%>
<% } -%>
<% if ! $chrony::cmdacl.empty { -%>
Copy link
Member

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.

Copy link
Contributor Author

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.
Copy link
Contributor

@aboe76 aboe76 left a 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

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ekohl ekohl merged commit f65cccf into voxpupuli:master Jul 10, 2020
@chrekh chrekh deleted the epp branch July 10, 2020 12:59
@ekohl ekohl linked an issue Jul 11, 2020 that may be closed by this pull request
@ekohl ekohl linked an issue Jul 11, 2020 that may be closed by this pull request
# NTP servers
<% $chrony::servers.each |$server| { -%>
server <%= $server.flatten.join(' ') %>
<% } -%>
Copy link
Contributor Author

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.

kenyon added a commit to kenyon/puppet-chrony that referenced this pull request Nov 16, 2020
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: ['']
kenyon added a commit to kenyon/puppet-chrony that referenced this pull request Nov 16, 2020
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: ['']
kenyon added a commit that referenced this pull request Nov 17, 2020
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(' ') %>
Copy link
Member

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 -%>

Copy link
Member

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.

alexjfisher added a commit to alexjfisher/puppet-chrony that referenced this pull request Jan 4, 2021
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.
alexjfisher added a commit to alexjfisher/puppet-chrony that referenced this pull request Jan 4, 2021
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.
alexjfisher added a commit to alexjfisher/puppet-chrony that referenced this pull request Jan 4, 2021
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.
alexjfisher added a commit to alexjfisher/puppet-chrony that referenced this pull request Jan 4, 2021
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.
Uuq114 pushed a commit to Uuq114/puppet-chrony that referenced this pull request Aug 21, 2023
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.
bmagistro added a commit to bmagistro/puppet-chrony that referenced this pull request Jan 4, 2024
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]>
bmagistro added a commit to bmagistro/puppet-chrony that referenced this pull request Jan 4, 2024
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]>
bmagistro added a commit to bmagistro/puppet-chrony that referenced this pull request Jan 4, 2024
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]>
kenyon pushed a commit to bmagistro/puppet-chrony that referenced this pull request Feb 26, 2024
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants