Skip to content

Commit

Permalink
Merge pull request #188 from nanliu/iburst_option
Browse files Browse the repository at this point in the history
Add support for iburst option
  • Loading branch information
cyberious committed Jul 30, 2014
2 parents cd6d3e2 + bb23ee1 commit 08959fb
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 22 deletions.
4 changes: 4 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ Disables monitoring of ntp.

Sets the location of the drift file for ntp.

####`iburst_enable`

Set the iburst option in the ntp configuration. If enabled the option is set for every ntp peer.

####`keys_controlkey`

The key to use as the control key.
Expand Down
2 changes: 2 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
$disable_monitor = $ntp::params::disable_monitor,
$driftfile = $ntp::params::driftfile,
$logfile = $ntp::params::logfile,
$iburst_enable = $ntp::params::iburst_enable,
$keys_enable = $ntp::params::keys_enable,
$keys_file = $ntp::params::keys_file,
$keys_controlkey = $ntp::params::keys_controlkey,
Expand All @@ -29,6 +30,7 @@
validate_bool($disable_monitor)
validate_absolute_path($driftfile)
if $logfile { validate_absolute_path($logfile) }
validate_bool($iburst_enable)
validate_bool($keys_enable)
validate_re($keys_controlkey, ['^\d+$', ''])
validate_re($keys_requestkey, ['^\d+$', ''])
Expand Down
45 changes: 27 additions & 18 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,21 @@

case $::osfamily {
'AIX': {
$config = '/etc/ntp.conf'
$keys_file = '/etc/ntp.keys'
$driftfile = '/etc/ntp.drift'
$package_name = [ 'bos.net.tcp.client' ]
$config = '/etc/ntp.conf'
$keysfile = '/etc/ntp.keys'
$driftfile = '/etc/ntp.drift'
$package_name = [ 'bos.net.tcp.client' ]
$restrict = [
'default nomodify notrap nopeer noquery',
'127.0.0.1',
]
$service_name = 'xntpd'
$servers = [
'0.debian.pool.ntp.org iburst',
'1.debian.pool.ntp.org iburst',
'2.debian.pool.ntp.org iburst',
'3.debian.pool.ntp.org iburst',
$service_name = 'xntpd'
$iburst_enable = true
$servers = [
'0.debian.pool.ntp.org',
'1.debian.pool.ntp.org',
'2.debian.pool.ntp.org',
'3.debian.pool.ntp.org',
]
}
'Debian': {
Expand All @@ -51,11 +52,12 @@
'-6 ::1',
]
$service_name = 'ntp'
$iburst_enable = true
$servers = [
'0.debian.pool.ntp.org iburst',
'1.debian.pool.ntp.org iburst',
'2.debian.pool.ntp.org iburst',
'3.debian.pool.ntp.org iburst',
'0.debian.pool.ntp.org',
'1.debian.pool.ntp.org',
'2.debian.pool.ntp.org',
'3.debian.pool.ntp.org',
]
}
'RedHat': {
Expand All @@ -70,6 +72,7 @@
'-6 ::1',
]
$service_name = 'ntpd'
$iburst_enable = false
$servers = [
'0.centos.pool.ntp.org',
'1.centos.pool.ntp.org',
Expand All @@ -88,6 +91,7 @@
'-6 ::1',
]
$service_name = 'ntp'
$iburst_enable = false
$servers = [
'0.opensuse.pool.ntp.org',
'1.opensuse.pool.ntp.org',
Expand All @@ -107,11 +111,12 @@
'-6 ::1',
]
$service_name = 'ntpd'
$iburst_enable = true
$servers = [
'0.freebsd.pool.ntp.org iburst maxpoll 9',
'1.freebsd.pool.ntp.org iburst maxpoll 9',
'2.freebsd.pool.ntp.org iburst maxpoll 9',
'3.freebsd.pool.ntp.org iburst maxpoll 9',
'0.freebsd.pool.ntp.org maxpoll 9',
'1.freebsd.pool.ntp.org maxpoll 9',
'2.freebsd.pool.ntp.org maxpoll 9',
'3.freebsd.pool.ntp.org maxpoll 9',
]
}
'Archlinux': {
Expand All @@ -126,6 +131,7 @@
'-6 ::1',
]
$service_name = 'ntpd'
$iburst_enable = false
$servers = [
'0.pool.ntp.org',
'1.pool.ntp.org',
Expand All @@ -147,6 +153,7 @@
'-6 ::1',
]
$service_name = 'network/ntp'
$iburst_enable = false
$servers = [
'0.pool.ntp.org',
'1.pool.ntp.org',
Expand All @@ -167,6 +174,7 @@
'-6 ::1',
]
$service_name = 'ntpd'
$iburst_enable = false
$servers = [
'0.gentoo.pool.ntp.org',
'1.gentoo.pool.ntp.org',
Expand All @@ -190,6 +198,7 @@
'-6 ::1',
]
$service_name = 'ntpd'
$iburst_enable = false
$servers = [
'0.gentoo.pool.ntp.org',
'1.gentoo.pool.ntp.org',
Expand Down
2 changes: 1 addition & 1 deletion spec/acceptance/ntp_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

case fact('osfamily')
when 'FreeBSD'
line = '0.freebsd.pool.ntp.org iburst maxpoll 9'
line = '0.freebsd.pool.ntp.org maxpoll 9 iburst'
when 'Debian'
line = '0.debian.pool.ntp.org iburst'
when 'RedHat'
Expand Down
30 changes: 28 additions & 2 deletions spec/classes/ntp_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,32 @@
end
end
end

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

it do
should contain_file('/etc/ntp.conf').with({
'content' => /iburst\n/,
})
end
end

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

it do
should_not contain_file('/etc/ntp.conf').with({
'content' => /iburst\n/,
})
end
end
end
end

context 'ntp::config' do
Expand Down Expand Up @@ -204,7 +230,7 @@

it 'uses the debian ntp servers by default' do
should contain_file('/etc/ntp.conf').with({
'content' => /server \d.debian.pool.ntp.org iburst/,
'content' => /server \d.debian.pool.ntp.org iburst\n/,
})
end
end
Expand Down Expand Up @@ -234,7 +260,7 @@

it 'uses the freebsd ntp servers by default' do
should contain_file('/etc/ntp.conf').with({
'content' => /server \d.freebsd.pool.ntp.org iburst maxpoll 9/,
'content' => /server \d.freebsd.pool.ntp.org maxpoll 9 iburst/,
})
end
end
Expand Down
2 changes: 1 addition & 1 deletion templates/ntp.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ interface listen <%= interface %>
<% end -%>

<% [@servers].flatten.each do |server| -%>
server <%= server %><% if @preferred_servers.include?(server) -%> prefer<% end %>
server <%= server %><% if @iburst_enable == true -%> iburst<% end %><% if @preferred_servers.include?(server) -%> prefer<% end %>
<% end -%>

<% if scope.lookupvar('::is_virtual') == "false" or @udlc -%>
Expand Down

0 comments on commit 08959fb

Please sign in to comment.