Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add parameter for interfaces to ignore #305

Merged
merged 1 commit into from
Feb 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ Specifies whether to enable the iburst option for every NTP peer. Valid options:

Specifies one or more network interfaces for NTP to listen on. Valid options: array. Default value: [ ]

####`interfaces_ignore`

Specifies one or more ignore pattern for the NTP listener configuration (e.g. all, wildcard, ipv6, ...). Valid options: array. Default value: [ ]

####`keys_controlkey`

Provides a control key to be used by NTP. Valid options: string. Default value: ' '
Expand Down
1 change: 1 addition & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
$preferred_servers = $ntp::params::preferred_servers,
$restrict = $ntp::params::restrict,
$interfaces = $ntp::params::interfaces,
$interfaces_ignore = $ntp::params::interfaces_ignore,
$servers = $ntp::params::servers,
$service_enable = $ntp::params::service_enable,
$service_ensure = $ntp::params::service_ensure,
Expand Down
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
$udlc = false
$udlc_stratum = '10'
$interfaces = []
$interfaces_ignore = []
$disable_auth = false
$disable_kernel = false
$disable_monitor = true
Expand Down
23 changes: 23 additions & 0 deletions spec/classes/ntp_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,29 @@
end
end

describe 'specified ignore interfaces' do
context "when set" do
let(:params) {{
:interfaces => ['a.b.c.d'],
:interfaces_ignore => ['wildcard', 'ipv6']
}}

it { should contain_file('/etc/ntp.conf').with({
'content' => /interface ignore wildcard\ninterface ignore ipv6\ninterface listen a.b.c.d/})
}
end
context "when not set" do
let(:params) {{
:interfaces => ['127.0.0.1'],
:servers => ['a', 'b', 'c', 'd'],
}}

it { should contain_file('/etc/ntp.conf').with({
'content' => /interface ignore wildcard\ninterface listen 127.0.0.1/})
}
end
end

describe 'with parameter disable_auth' do
context 'when set to true' do
let(:params) {{
Expand Down
6 changes: 6 additions & 0 deletions templates/ntp.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,15 @@ restrict <%= restrict %>
<% end -%>

<% if @interfaces != [] -%>
<% if @interfaces_ignore != [] -%>
<% @interfaces_ignore.flatten.each do |interface| -%>
interface ignore <%= interface %>
<% end -%>
<% else -%>
# Ignore wildcard interface and only listen on the following specified
# interfaces
interface ignore wildcard
<% end -%>
<% @interfaces.flatten.each do |interface| -%>
interface listen <%= interface %>
<% end -%>
Expand Down