Skip to content

Commit 732a062

Browse files
authored
Merge pull request voxpupuli#228 from cirrax/dev_cirrax
Allow to specify options on Debian systems
2 parents f5af8ef + b9ab788 commit 732a062

File tree

7 files changed

+44
-10
lines changed

7 files changed

+44
-10
lines changed

REFERENCE.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -880,23 +880,23 @@ Default value: `undef`
880880

881881
Data type: `Optional[Stdlib::Absolutepath]`
882882

883-
The full path to the chronyd options file, typically /etc/sysconfig/chronyd
883+
The full path to the chronyd options file, typically /etc/sysconfig/chronyd on RedHat, /etc/default/chrony on Debian
884884

885885
Default value: `undef`
886886

887887
##### <a name="-chrony--options"></a>`options`
888888

889-
Data type: `Optional[String[1]]`
889+
Data type: `Optional[String]`
890890

891-
Options to pass to the chrony daemon via /etc/sysconfig/chronyd file.
891+
Options to pass to the chrony daemon via $options_file file.
892892

893893
Default value: `undef`
894894

895895
##### <a name="-chrony--options_template"></a>`options_template`
896896

897897
Data type: `String[1]`
898898

899-
This determines which template puppet should use for the chrony options (sysconfig) file.
899+
This determines which template puppet should use for the chrony options (sysconfig|default) file.
900900

901901
Default value: `'chrony/chronyd.epp'`
902902

data/Debian.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ chrony::leapsectz: right/UTC
55
chrony::makestep_seconds: 1
66
chrony::maxupdateskew: 100.0
77
chrony::ntsdumpdir: /var/lib/chrony
8+
chrony::options_template: chrony/chronyd_default.epp
9+
chrony::options_file: /etc/default/chrony

data/RedHat.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ chrony::config_keys: /etc/chrony.keys
44
chrony::config: /etc/chrony.conf
55
chrony::wait_manage: true
66
chrony::options_file: /etc/sysconfig/chronyd
7+
chrony::options: ''

manifests/config.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
}
3737
}
3838

39-
if $chrony::options_file {
39+
if $chrony::options_file and $chrony::options {
4040
file { $chrony::options_file:
4141
ensure => file,
4242
owner => 0,

manifests/init.pp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,11 +256,11 @@
256256
# @param acquisitionport
257257
# Sets the acquisitionport for client queries
258258
# @param options_file
259-
# The full path to the chronyd options file, typically /etc/sysconfig/chronyd
259+
# The full path to the chronyd options file, typically /etc/sysconfig/chronyd on RedHat, /etc/default/chrony on Debian
260260
# @param options
261-
# Options to pass to the chrony daemon via /etc/sysconfig/chronyd file.
261+
# Options to pass to the chrony daemon via $options_file file.
262262
# @param options_template
263-
# This determines which template puppet should use for the chrony options (sysconfig) file.
263+
# This determines which template puppet should use for the chrony options (sysconfig|default) file.
264264
# @param ptpport
265265
# open port to send and receive NTP messages contained in PTP event messages (NTP-over-PTP)
266266
# @param ptpdomain
@@ -348,7 +348,7 @@
348348
Optional[Integer[0]] $ntsrotate = undef,
349349
Optional[Integer[1,65535]] $acquisitionport = undef,
350350
Optional[Stdlib::Absolutepath] $options_file = undef,
351-
Optional[String[1]] $options = undef,
351+
Optional[String] $options = undef,
352352
String[1] $options_template = 'chrony/chronyd.epp',
353353
Optional[Integer[0]] $ptpport = undef,
354354
Optional[Integer[0,255]] $ptpdomain = undef,

spec/classes/chrony_spec.rb

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,10 @@
415415
)
416416
end
417417

418+
it 'does not create /etc/default/chrony' do
419+
is_expected.not_to contain_file('/etc/default/chrony')
420+
end
421+
418422
if (facts[:os]['release']['major'] = '8')
419423
context 'on RedHat 8 family with default parameters' do
420424
it 'contains an empty OPTIONS line' do
@@ -439,9 +443,33 @@
439443
with_content(%r{^OPTIONS="-4 -u chrony"$})
440444
end
441445
end
446+
when 'Debian'
447+
it 'does not create /etc/sysconfig/chronyd' do
448+
is_expected.not_to contain_file('/etc/sysconfig/chronyd')
449+
end
450+
451+
context 'with no options parameter' do
452+
it {
453+
is_expected.not_to contain_file('/etc/default/chrony')
454+
}
455+
end
456+
457+
context 'with custom options parameter' do
458+
let(:params) { { options: '-4 -u chrony' } }
459+
460+
it 'contains the custom OPTIONS line' do
461+
is_expected.to contain_file('/etc/default/chrony').
462+
with_content(%r{^DAEMON_OPTS="-4 -u chrony"$}).
463+
with_ensure('file').
464+
with_owner('0').
465+
with_group('0').
466+
with_mode('0644')
467+
end
468+
end
442469
else
443-
it 'on non-RedHat families' do
470+
it 'on non-RedHat/Debian families' do
444471
is_expected.not_to contain_file('/etc/sysconfig/chronyd')
472+
is_expected.not_to contain_file('/etc/default/chrony')
445473
end
446474
end
447475
end

templates/chronyd_default.epp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# This file is managed by Puppet. Do not edit!
2+
# Command-line options for chronyd
3+
DAEMON_OPTS="<%= $chrony::options %>"

0 commit comments

Comments
 (0)