Skip to content

Commit 5317d44

Browse files
committed
Merge pull request #282 from petems/MODULES-2210-add_tos
MODULES-2210 Add TOS Parameter
2 parents ee1105b + c745262 commit 5317d44

File tree

5 files changed

+73
-0
lines changed

5 files changed

+73
-0
lines changed

README.markdown

+24
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,30 @@ Tells Puppet what NTP service to manage. Valid options: string. Default value: v
277277

278278
Tells puppet to change stepout. Applies only if `tinker` value is 'true'. Valid options: unsigned shortint digit. Default value: undef.
279279

280+
####`tos`
281+
282+
Tells Puppet to enable tos options. Valid options: 'true' of 'false'. Default value: 'false'
283+
284+
####`tos_minclock`
285+
286+
Specifies the minclock tos option. Valid options: numeric. Default value: 3
287+
288+
####`tos_minsane`
289+
290+
Specifies the minsane tos option. Valid options: numeric. Default value: 1
291+
292+
####`tos_floor`
293+
294+
Specifies the floor tos option. Valid options: numeric. Default value: 1
295+
296+
####`tos_ceiling`
297+
298+
Specifies the ceiling tos option. Valid options: numeric. Default value: 15
299+
300+
####`tos_cohort`
301+
302+
Specifies the cohort tos option. Valid options: '0' or '1'. Default value: 0
303+
280304
####`tinker`
281305

282306
Tells Puppet to enable tinker options. Valid options: 'true' of 'false'. Default value: 'false'

manifests/init.pp

+12
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@
3232
$service_name = $ntp::params::service_name,
3333
$stepout = $ntp::params::stepout,
3434
$tinker = $ntp::params::tinker,
35+
$tos = $ntp::params::tos,
36+
$tos_minclock = $ntp::params::tos_minclock,
37+
$tos_minsane = $ntp::params::tos_minsane,
38+
$tos_floor = $ntp::params::tos_floor,
39+
$tos_ceiling = $ntp::params::tos_ceiling,
40+
$tos_cohort = $ntp::params::tos_cohort,
3541
$udlc = $ntp::params::udlc,
3642
$udlc_stratum = $ntp::params::udlc_stratum,
3743
) inherits ntp::params {
@@ -66,6 +72,12 @@
6672
validate_string($service_name)
6773
if $stepout { validate_numeric($stepout, 65535, 0) }
6874
validate_bool($tinker)
75+
validate_bool($tos)
76+
if $tos_minclock { validate_numeric($tos_minclock) }
77+
if $tos_minsane { validate_numeric($tos_minsane) }
78+
if $tos_floor { validate_numeric($tos_floor) }
79+
if $tos_ceiling { validate_numeric($tos_ceiling) }
80+
if $tos_cohort { validate_re($tos_cohort, '^[0|1]$', "Must be 0 or 1, got: ${tos_cohort}") }
6981
validate_bool($udlc)
7082
validate_array($peers)
7183

manifests/params.pp

+6
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@
2121
$interfaces = []
2222
$disable_auth = false
2323
$broadcastclient = false
24+
$tos = false
25+
$tos_minclock = '3'
26+
$tos_minsane = '1'
27+
$tos_floor = '1'
28+
$tos_ceiling = '15'
29+
$tos_cohort = '0'
2430

2531
# Allow a list of fudge options
2632
$fudge = []

spec/classes/ntp_spec.rb

+26
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,32 @@
472472
end
473473
end
474474

475+
describe 'with parameter tos' do
476+
context 'when set to true' do
477+
let(:params) {{
478+
:tos => true,
479+
}}
480+
481+
it 'should contain logfile setting' do
482+
should contain_file('/etc/ntp.conf').with({
483+
'content' => /^tos/,
484+
})
485+
end
486+
end
487+
488+
context 'when set to false' do
489+
let(:params) {{
490+
:tos => false,
491+
}}
492+
493+
it 'should not contain a logfile line' do
494+
should_not contain_file('/etc/ntp.conf').with({
495+
'content' => /^tos/,
496+
})
497+
end
498+
end
499+
end
500+
475501
describe 'peers' do
476502
context 'when empty' do
477503
let(:params) do

templates/ntp.conf.erb

+5
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,8 @@ fudge <%= entry %>
9090
# Leapfile
9191
leapfile <%= @leapfile %>
9292
<% end -%>
93+
94+
<% if @tos == true -%>
95+
tos <% if @minclock -%> minclock <%= @tos_minclock %><% end %><% if @tos_minsane -%> minsane <%= @tos_minsane %><% end %><% if @tos_floor -%> floor <%= @tos_floor %><% end %><% if @tos_ceiling -%> ceiling <%= @tos_ceiling %><% end %><% if @tos_cohort -%> cohort <%= @tos_cohort %><% end %>
96+
<% end %>
97+

0 commit comments

Comments
 (0)