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

Add support for several NTS settings. #145

Merged
merged 5 commits into from
Mar 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,24 @@
# Sets the maximum root distance of a source to be acceptable for synchronisation of the clock.
# @param maxslewrate
# Maximum rate for chronyd to slew the time. Only float type values possible, for example: `maxslewrate 1000.0`.
# @param ntsserverkey
# This directive specifies a file containing a private key in the PEM format for chronyd to operate as an NTS server.
# @param ntsservercert
# This directive specifies a file containing a certificate in the PEM format for chronyd to operate as an NTS server.
# @param ntsport
# This directive specifies the TCP port on which chronyd will provide the NTS Key Establishment (NTS-KE) service.
# @param maxntsconnections
# This directive specifies the maximum number of concurrent NTS-KE connections per process that the NTS server will accept.
# @param ntsprocesses
# This directive specifies how many helper processes will chronyd operating as an NTS server start for handling client NTS-KE requests in order to improve
# performance with multi-core CPUs and multithreading.
# @param ntsdumpdir
# This directive specifies a directory where chronyd operating as an NTS server can save the keys which encrypt NTS cookies provided to clients.
# @param ntsntpserver
# This directive specifies the hostname (as a fully qualified domain name) or address of the NTP server(s) which is provided in the NTS-KE response to the
# clients.
# @param ntsrotate
# This directive specifies the rotation interval (in seconds) of the server key which encrypts the NTS cookies.
# @param clientlog
# Determines whether to log client accesses.
# @param clientloglimit
Expand Down Expand Up @@ -272,6 +290,14 @@
Boolean $rtconutc = false,
Variant[Hash,Array[String]] $hwtimestamps = [],
Optional[Stdlib::Unixpath] $dumpdir = undef,
Optional[Stdlib::Absolutepath] $ntsserverkey = undef,
Optional[Stdlib::Absolutepath] $ntsservercert = undef,
Optional[Stdlib::Port] $ntsport = undef,
Optional[Integer[0]] $maxntsconnections = undef,
Optional[Integer[0]] $ntsprocesses = undef,
Optional[Stdlib::Absolutepath] $ntsdumpdir = undef,
Optional[String] $ntsntpserver = undef,
Optional[Integer[0]] $ntsrotate = undef,
) {
if ! $config_keys_manage and $chrony_password != 'unset' {
fail("Setting \$config_keys_manage false and \$chrony_password at same time in ${module_name} is not possible.")
Expand Down
34 changes: 33 additions & 1 deletion spec/classes/chrony_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,15 @@
hwtimestamps: ['eth0'],
driftfile: '/var/tmp/chrony.drift',
rtcsync: false,
dumpdir: '/var/tmp'
dumpdir: '/var/tmp',
ntsserverkey: '/tmp/cert.key',
ntsservercert: '/tmp/cert.pem',
ntsport: 12,
maxntsconnections: 32,
ntsprocesses: 5,
ntsdumpdir: '/tmp/ntsdump',
ntsntpserver: 'foo.bar',
ntsrotate: 8
}
end

Expand All @@ -181,6 +189,14 @@
it { is_expected.to contain_file('/etc/chrony.keys').with_content(sensitive("0 sunny\n")) }
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*maxdistance 16\.0$}) }
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*maxupdateskew 1000\.0$}) }
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*ntsserverkey /tmp/cert.key$}) }
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*ntsservercert /tmp/cert.pem$}) }
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*ntsport 12$}) }
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*maxntsconnections 32$}) }
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*ntsprocesses 5$}) }
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*ntsdumpdir /tmp/ntsdump$}) }
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*ntsntpserver foo.bar$}) }
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*ntsrotate 8$}) }
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*confdir /tmp/chroconf$}) }
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*sourcedir /tmp/chrosources$}) }
end
Expand Down Expand Up @@ -212,6 +228,14 @@
it { is_expected.to contain_file('/etc/chrony.keys').with_group('mrt') }
it { is_expected.to contain_file('/etc/chrony.keys').with_replace(true) }
it { is_expected.to contain_file('/etc/chrony.keys').with_content(sensitive("0 sunny\n")) }
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*ntsserverkey /tmp/cert.key$}) }
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*ntsservercert /tmp/cert.pem$}) }
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*ntsport 12$}) }
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*maxntsconnections 32$}) }
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*ntsprocesses 5$}) }
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*ntsdumpdir /tmp/ntsdump$}) }
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*ntsntpserver foo.bar$}) }
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*ntsrotate 8$}) }
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*confdir /tmp/chroconf$}) }
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*sourcedir /tmp/chrosources$}) }
end
Expand Down Expand Up @@ -243,6 +267,14 @@
it { is_expected.to contain_file('/etc/chrony/chrony.keys').with_group('mrt') }
it { is_expected.to contain_file('/etc/chrony/chrony.keys').with_replace(true) }
it { is_expected.to contain_file('/etc/chrony/chrony.keys').with_content(sensitive("0 sunny\n")) }
it { is_expected.to contain_file('/etc/chrony/chrony.conf').with_content(%r{^\s*ntsserverkey /tmp/cert.key$}) }
it { is_expected.to contain_file('/etc/chrony/chrony.conf').with_content(%r{^\s*ntsservercert /tmp/cert.pem$}) }
it { is_expected.to contain_file('/etc/chrony/chrony.conf').with_content(%r{^\s*ntsport 12$}) }
it { is_expected.to contain_file('/etc/chrony/chrony.conf').with_content(%r{^\s*maxntsconnections 32$}) }
it { is_expected.to contain_file('/etc/chrony/chrony.conf').with_content(%r{^\s*ntsprocesses 5$}) }
it { is_expected.to contain_file('/etc/chrony/chrony.conf').with_content(%r{^\s*ntsdumpdir /tmp/ntsdump$}) }
it { is_expected.to contain_file('/etc/chrony/chrony.conf').with_content(%r{^\s*ntsntpserver foo.bar$}) }
it { is_expected.to contain_file('/etc/chrony/chrony.conf').with_content(%r{^\s*ntsrotate 8$}) }
it { is_expected.to contain_file('/etc/chrony/chrony.conf').with_content(%r{^\s*confdir /tmp/chroconf$}) }
it { is_expected.to contain_file('/etc/chrony/chrony.conf').with_content(%r{^\s*sourcedir /tmp/chrosources$}) }
end
Expand Down
40 changes: 40 additions & 0 deletions templates/chrony.conf.epp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,46 @@ maxupdateskew <%= $chrony::maxupdateskew %>
# https://chrony.tuxfamily.org/doc/3.4/chrony.conf.html#maxslewrate
maxslewrate <%= $chrony::maxslewrate %>
<% } -%>
<% if $chrony::ntsserverkey { -%>

# https://chrony.tuxfamily.org/doc/4.0/chrony.conf.html#ntsserverkey
ntsserverkey <%= $chrony::ntsserverkey %>
<% } -%>
<% if $chrony::ntsservercert { -%>

# https://chrony.tuxfamily.org/doc/4.0/chrony.conf.html#ntsservercert
ntsservercert <%= $chrony::ntsservercert %>
<% } -%>
<% if $chrony::ntsport { -%>

# https://chrony.tuxfamily.org/doc/4.0/chrony.conf.html#ntsport
ntsport <%= $chrony::ntsport %>
<% } -%>
<% if $chrony::maxntsconnections { -%>

# https://chrony.tuxfamily.org/doc/4.0/chrony.conf.html#maxntsconnections
maxntsconnections <%= $chrony::maxntsconnections %>
<% } -%>
<% if $chrony::ntsprocesses { -%>

# https://chrony.tuxfamily.org/doc/4.0/chrony.conf.html#ntsprocesses
ntsprocesses <%= $chrony::ntsprocesses %>
<% } -%>
<% if $chrony::ntsdumpdir { -%>

# https://chrony.tuxfamily.org/doc/4.0/chrony.conf.html#ntsdumpdir
ntsdumpdir <%= $chrony::ntsdumpdir %>
<% } -%>
<% if $chrony::ntsntpserver { -%>

# https://chrony.tuxfamily.org/doc/4.0/chrony.conf.html#ntsntpserver
ntsntpserver <%= $chrony::ntsntpserver %>
<% } -%>
<% if $chrony::ntsrotate { -%>

# https://chrony.tuxfamily.org/doc/4.0/chrony.conf.html#ntsrotate
ntsrotate <%= $chrony::ntsrotate %>
<% } -%>
<% if $chrony::smoothtime { -%>

# https://chrony.tuxfamily.org/doc/3.4/chrony.conf.html#smoothtime
Expand Down