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

MODULES-2210 Add TOS Parameter #282

Merged
merged 1 commit into from
Jul 22, 2015
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
24 changes: 24 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,30 @@ Tells Puppet what NTP service to manage. Valid options: string. Default value: v

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

####`tos`

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

####`tos_minclock`

Specifies the minclock tos option. Valid options: numeric. Default value: 3

####`tos_minsane`

Specifies the minsane tos option. Valid options: numeric. Default value: 1

####`tos_floor`

Specifies the floor tos option. Valid options: numeric. Default value: 1

####`tos_ceiling`

Specifies the ceiling tos option. Valid options: numeric. Default value: 15

####`tos_cohort`

Specifies the cohort tos option. Valid options: '0' or '1'. Default value: 0

Copy link
Contributor

Choose a reason for hiding this comment

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

For all of these Default value: varies by operating system, it looks like params actually has a consistent default for all oses, so that should probably be listed instead.

Copy link
Author

Choose a reason for hiding this comment

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

Good point, will fix 👍

####`tinker`

Tells Puppet to enable tinker options. Valid options: 'true' of 'false'. Default value: 'false'
Expand Down
12 changes: 12 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
$service_name = $ntp::params::service_name,
$stepout = $ntp::params::stepout,
$tinker = $ntp::params::tinker,
$tos = $ntp::params::tos,
$tos_minclock = $ntp::params::tos_minclock,
$tos_minsane = $ntp::params::tos_minsane,
$tos_floor = $ntp::params::tos_floor,
$tos_ceiling = $ntp::params::tos_ceiling,
$tos_cohort = $ntp::params::tos_cohort,
$udlc = $ntp::params::udlc,
$udlc_stratum = $ntp::params::udlc_stratum,
) inherits ntp::params {
Expand Down Expand Up @@ -66,6 +72,12 @@
validate_string($service_name)
if $stepout { validate_numeric($stepout, 65535, 0) }
validate_bool($tinker)
validate_bool($tos)
if $tos_minclock { validate_numeric($tos_minclock) }
if $tos_minsane { validate_numeric($tos_minsane) }
if $tos_floor { validate_numeric($tos_floor) }
if $tos_ceiling { validate_numeric($tos_ceiling) }
if $tos_cohort { validate_re($tos_cohort, '^[0|1]$', "Must be 0 or 1, got: ${tos_cohort}") }
validate_bool($udlc)
validate_array($peers)

Expand Down
6 changes: 6 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
$interfaces = []
$disable_auth = false
$broadcastclient = false
$tos = false
$tos_minclock = '3'
$tos_minsane = '1'
$tos_floor = '1'
$tos_ceiling = '15'
$tos_cohort = '0'

# Allow a list of fudge options
$fudge = []
Expand Down
26 changes: 26 additions & 0 deletions spec/classes/ntp_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,32 @@
end
end

describe 'with parameter tos' do
context 'when set to true' do
let(:params) {{
:tos => true,
}}

it 'should contain logfile setting' do
should contain_file('/etc/ntp.conf').with({
'content' => /^tos/,
})
end
end

context 'when set to false' do
let(:params) {{
:tos => false,
}}

it 'should not contain a logfile line' do
should_not contain_file('/etc/ntp.conf').with({
'content' => /^tos/,
})
end
end
end

describe 'peers' do
context 'when empty' do
let(:params) do
Expand Down
5 changes: 5 additions & 0 deletions templates/ntp.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,8 @@ fudge <%= entry %>
# Leapfile
leapfile <%= @leapfile %>
<% end -%>

<% if @tos == true -%>
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 %>
<% end %>