Skip to content

Commit b6bb239

Browse files
Ketil Gjerdetphoney
authored andcommitted
Added leapfile parameter
1 parent d654068 commit b6bb239

6 files changed

Lines changed: 40 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ spec/fixtures/
77
coverage/
88
.idea/
99
*.iml
10+
log/

README.markdown

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,10 @@ Provides a request key to be used by NTP. Valid options: string. Default value:
191191
#### `keys_trusted`:
192192
Provides one or more keys to be trusted by NTP. Valid options: array of keys. Default value: [ ]
193193

194+
#### `leapfile`
195+
196+
Specifies a leap second file for NTP to use. Valid options: string containing an absolute path. Default value: ' '
197+
194198
#### `logfile`
195199

196200
Specifies a log file for NTP to use instead of syslog. Valid options: string containing an absolute path. Default value: ' '

manifests/init.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
$disable_monitor = $ntp::params::disable_monitor,
88
$fudge = $ntp::params::fudge,
99
$driftfile = $ntp::params::driftfile,
10+
$leapfile = $ntp::params::leapfile,
1011
$logfile = $ntp::params::logfile,
1112
$iburst_enable = $ntp::params::iburst_enable,
1213
$keys_enable = $ntp::params::keys_enable,
@@ -42,6 +43,7 @@
4243
validate_bool($disable_monitor)
4344
validate_absolute_path($driftfile)
4445
if $logfile { validate_absolute_path($logfile) }
46+
if $leapfile { validate_absolute_path($leapfile) }
4547
validate_bool($iburst_enable)
4648
validate_bool($keys_enable)
4749
validate_re($keys_controlkey, ['^\d+$', ''])

manifests/params.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
$keys_trusted = []
1010
$logfile = undef
1111
$minpoll = undef
12+
$leapfile = undef
1213
$package_ensure = 'present'
1314
$peers = []
1415
$preferred_servers = []

spec/classes/ntp_spec.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,33 @@
414414
end
415415
end
416416

417+
describe 'with parameter leapfile' do
418+
context 'when set to true' do
419+
let(:params) {{
420+
:servers => ['a', 'b', 'c', 'd'],
421+
:leapfile => '/etc/leap-seconds.3629404800',
422+
}}
423+
424+
it 'should contain leapfile setting' do
425+
should contain_file('/etc/ntp.conf').with({
426+
'content' => /^leapfile \/etc\/leap-seconds\.3629404800\n/,
427+
})
428+
end
429+
end
430+
431+
context 'when set to false' do
432+
let(:params) {{
433+
:servers => ['a', 'b', 'c', 'd'],
434+
}}
435+
436+
it 'should not contain a leapfile line' do
437+
should_not contain_file('/etc/ntp.conf').with({
438+
'content' => /leapfile /,
439+
})
440+
end
441+
end
442+
end
443+
417444
describe 'with parameter logfile' do
418445
context 'when set to true' do
419446
let(:params) {{

templates/ntp.conf.erb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,8 @@ controlkey <%= @keys_controlkey %>
8585
<% [@fudge].flatten.each do |entry| -%>
8686
fudge <%= entry %>
8787
<% end -%>
88+
89+
<% unless @leapfile.nil? -%>
90+
# Leapfile
91+
leapfile <%= @leapfile %>
92+
<% end -%>

0 commit comments

Comments
 (0)