Skip to content

Commit

Permalink
Merge pull request redhat-openstack#253 from mhaskel/MODULES-1836
Browse files Browse the repository at this point in the history
MODULES-1836 - Added support for peers
  • Loading branch information
hunner committed Apr 8, 2015
2 parents 286acba + e2f7aa9 commit 789d47a
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ Tells Puppet what NTP package to manage. Valid options: string. Default value: '

Specifies whether NTP should "panic" in the event of a very large clock skew. Valid options: 'true' or 'false'. Default value: 'true' (except on virtual machines, where major time shifts are normal)

####`peers`

List of ntp servers which the local clock can be synchronised against, or which can synchronise against the local clock.

####`preferred_servers`

Specifies one or more preferred peers. Puppet will append 'prefer' to each matching item in the `servers` array. Valid options: array. Default value: [ ]
Expand Down
4 changes: 3 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
$package_manage = $ntp::params::package_manage,
$package_name = $ntp::params::package_name,
$panic = $ntp::params::panic,
$peers = $ntp::params::peers,
$preferred_servers = $ntp::params::preferred_servers,
$restrict = $ntp::params::restrict,
$interfaces = $ntp::params::interfaces,
Expand All @@ -26,7 +27,7 @@
$service_ensure = $ntp::params::service_ensure,
$service_manage = $ntp::params::service_manage,
$service_name = $ntp::params::service_name,
$udlc = $ntp::params::udlc
$udlc = $ntp::params::udlc,
) inherits ntp::params {

validate_bool($broadcastclient)
Expand Down Expand Up @@ -55,6 +56,7 @@
validate_bool($service_manage)
validate_string($service_name)
validate_bool($udlc)
validate_array($peers)

if $autoupdate {
notice('autoupdate parameter has been deprecated and replaced with package_ensure. Set this to latest for the same behavior as autoupdate => true.')
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
$package_ensure = 'present'
$peers = []
$preferred_servers = []
$service_enable = true
$service_ensure = 'running'
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 @@ -291,6 +291,33 @@
end
end
end

describe 'peers' do
context 'when empty' do
let(:params) do
{
:peers => []
}
end

it 'should not contain a peer line' do
should contain_file('/etc/ntp.conf').without_content(/^peer/)
end
end

context 'set' do
let(:params) do
{
:peers => ['foo', 'bar'],
}
end

it 'should contain the peer lines' do
should contain_file('/etc/ntp.conf').with_content(/peer foo/)
should contain_file('/etc/ntp.conf').with_content(/peer bar/)
end
end
end
end
end

Expand Down
7 changes: 7 additions & 0 deletions templates/ntp.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ driftfile <%= @driftfile %>
logfile <%= @logfile %>
<% end -%>

<% unless @peers.empty? -%>
# Peers
<% [@peers].flatten.each do |peer| -%>
peer <%= peer %>
<% end -%>
<% end -%>

<% if @keys_enable -%>
keys <%= @keys_file %>
<% unless @keys_trusted.empty? -%>
Expand Down

0 comments on commit 789d47a

Please sign in to comment.