diff --git a/README.markdown b/README.markdown index b620621a..b975c837 100644 --- a/README.markdown +++ b/README.markdown @@ -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: ' ' diff --git a/manifests/init.pp b/manifests/init.pp index 774d88f4..064ec7da 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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, diff --git a/manifests/params.pp b/manifests/params.pp index ec538953..c3e549fe 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -21,6 +21,7 @@ $udlc = false $udlc_stratum = '10' $interfaces = [] + $interfaces_ignore = [] $disable_auth = false $disable_kernel = false $disable_monitor = true diff --git a/spec/classes/ntp_spec.rb b/spec/classes/ntp_spec.rb index b01717b6..1fd8c80a 100644 --- a/spec/classes/ntp_spec.rb +++ b/spec/classes/ntp_spec.rb @@ -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) {{ diff --git a/templates/ntp.conf.erb b/templates/ntp.conf.erb index c8c17677..8bc3a01a 100644 --- a/templates/ntp.conf.erb +++ b/templates/ntp.conf.erb @@ -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 -%>