diff --git a/.gitignore b/.gitignore index b5db85e05..874db461f 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ spec/fixtures/ coverage/ .idea/ *.iml +log/ diff --git a/README.markdown b/README.markdown index 3cf031018..353923f16 100644 --- a/README.markdown +++ b/README.markdown @@ -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: ' ' diff --git a/manifests/init.pp b/manifests/init.pp index 6bd815939..1eea5a036 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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, @@ -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+$', '']) diff --git a/manifests/params.pp b/manifests/params.pp index 765793c60..cf9c01180 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -9,6 +9,7 @@ $keys_trusted = [] $logfile = undef $minpoll = undef + $leapfile = undef $package_ensure = 'present' $peers = [] $preferred_servers = [] diff --git a/spec/acceptance/ntp_parameters_spec.rb b/spec/acceptance/ntp_parameters_spec.rb index 8c47e729a..2ac554d9c 100644 --- a/spec/acceptance/ntp_parameters_spec.rb +++ b/spec/acceptance/ntp_parameters_spec.rb @@ -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 diff --git a/spec/classes/ntp_spec.rb b/spec/classes/ntp_spec.rb index 169442f50..81489db6e 100644 --- a/spec/classes/ntp_spec.rb +++ b/spec/classes/ntp_spec.rb @@ -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) {{ diff --git a/templates/ntp.conf.erb b/templates/ntp.conf.erb index b2cb22628..c913569b8 100644 --- a/templates/ntp.conf.erb +++ b/templates/ntp.conf.erb @@ -85,3 +85,8 @@ controlkey <%= @keys_controlkey %> <% [@fudge].flatten.each do |entry| -%> fudge <%= entry %> <% end -%> + +<% unless @leapfile.nil? -%> +# Leapfile +leapfile <%= @leapfile %> +<% end -%>