Skip to content

Commit

Permalink
Merge pull request redhat-openstack#260 from tphoney/leapfile_fix
Browse files Browse the repository at this point in the history
Leapfile fix
  • Loading branch information
jonnytdevops committed Apr 20, 2015
2 parents d654068 + 7d30e16 commit 060c453
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ spec/fixtures/
coverage/
.idea/
*.iml
log/
4 changes: 4 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ Provides a request key to be used by NTP. Valid options: string. Default value:
#### `keys_trusted`:
Provides one or more keys to be trusted by NTP. Valid options: array of keys. Default value: [ ]

#### `leapfile`

Specifies a leap second file for NTP to use. Valid options: string containing an absolute path. Default value: ' '

#### `logfile`

Specifies a log file for NTP to use instead of syslog. Valid options: string containing an absolute path. Default value: ' '
Expand Down
2 changes: 2 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
$disable_monitor = $ntp::params::disable_monitor,
$fudge = $ntp::params::fudge,
$driftfile = $ntp::params::driftfile,
$leapfile = $ntp::params::leapfile,
$logfile = $ntp::params::logfile,
$iburst_enable = $ntp::params::iburst_enable,
$keys_enable = $ntp::params::keys_enable,
Expand Down Expand Up @@ -42,6 +43,7 @@
validate_bool($disable_monitor)
validate_absolute_path($driftfile)
if $logfile { validate_absolute_path($logfile) }
if $leapfile { validate_absolute_path($leapfile) }
validate_bool($iburst_enable)
validate_bool($keys_enable)
validate_re($keys_controlkey, ['^\d+$', ''])
Expand Down
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
$keys_trusted = []
$logfile = undef
$minpoll = undef
$leapfile = undef
$package_ensure = 'present'
$peers = []
$preferred_servers = []
Expand Down
16 changes: 8 additions & 8 deletions spec/acceptance/ntp_parameters_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,33 +139,33 @@ class { 'ntp':
end
end

describe 'panic => false' do
it 'enables the tinker panic setting' do
describe 'panic => 0' do
it 'disables the tinker panic setting' do
pp = <<-EOS
class { 'ntp':
panic => false,
panic => 0,
}
EOS
apply_manifest(pp, :catch_failures => true)
end

describe file("#{config}") do
its(:content) { should match 'tinker panic' }
its(:content) { should match 'tinker panic 0' }
end
end

describe 'panic => true' do
it 'disables the tinker panic setting' do
describe 'panic => 1' do
it 'enables the tinker panic setting' do
pp = <<-EOS
class { 'ntp':
panic => true,
panic => 1,
}
EOS
apply_manifest(pp, :catch_failures => true)
end

describe file("#{config}") do
its(:content) { should_not match 'tinker panic 0' }
its(:content) { should match 'tinker panic 1' }
end
end

Expand Down
27 changes: 27 additions & 0 deletions spec/classes/ntp_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,33 @@
end
end

describe 'with parameter leapfile' do
context 'when set to true' do
let(:params) {{
:servers => ['a', 'b', 'c', 'd'],
:leapfile => '/etc/leap-seconds.3629404800',
}}

it 'should contain leapfile setting' do
should contain_file('/etc/ntp.conf').with({
'content' => /^leapfile \/etc\/leap-seconds\.3629404800\n/,
})
end
end

context 'when set to false' do
let(:params) {{
:servers => ['a', 'b', 'c', 'd'],
}}

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

describe 'with parameter logfile' do
context 'when set to true' do
let(:params) {{
Expand Down
5 changes: 5 additions & 0 deletions templates/ntp.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,8 @@ controlkey <%= @keys_controlkey %>
<% [@fudge].flatten.each do |entry| -%>
fudge <%= entry %>
<% end -%>

<% unless @leapfile.nil? -%>
# Leapfile
leapfile <%= @leapfile %>
<% end -%>

0 comments on commit 060c453

Please sign in to comment.