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

Allow query zone #152

Merged
merged 3 commits into from
Jan 9, 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
6 changes: 6 additions & 0 deletions manifests/zone.pp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
# '192.168.100.102 port 1234' ]`. Defaults to an empty array, which
# means no forwarding will be done.
#
# [*allow_query*]
# An array of IP addresses from which queries should be allowed
# Defaults to an empty array, which allows all ip to query the zone
#
# [*also_notify*]
# This is an array of IP addresses and optional port numbers to
# which this DNS server will send notifies when the master DNS server
Expand Down Expand Up @@ -144,6 +148,7 @@
$zone_type = 'master',
$allow_transfer = [],
$allow_forwarder = [],
$allow_query =[],
$forward_policy = 'first',
$slave_masters = undef,
$zone_notify = undef,
Expand All @@ -158,6 +163,7 @@
if !member(['first', 'only'], $forward_policy) {
error('The forward policy can only be set to either first or only')
}
validate_array($allow_query)

validate_array($also_notify)
$valid_zone_notify = ['yes', 'no', 'explicit', 'master-only']
Expand Down
22 changes: 22 additions & 0 deletions spec/defines/dns__zone_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,28 @@
let(:title) { 'test.com' }
let(:facts) {{ :osfamily => 'Debian', :concat_basedir => '/mock_dir' }}

describe 'passing something other than an array to $allow_query ' do
let(:params) {{ :allow_query => '127.0.0.1' }}
it { should raise_error(Puppet::Error, /is not an Array/) }
end

describe 'passing an array to $allow_query' do
let(:params) {{ :allow_query => ['192.0.2.0', '2001:db8::/32'] }}
it { should_not raise_error }
it {
should contain_concat__fragment('named.conf.local.test.com.include').
with_content(/allow-query/)
}
it {
should contain_concat__fragment('named.conf.local.test.com.include').
with_content(/192\.0\.2\.0;/)
}
it {
should contain_concat__fragment('named.conf.local.test.com.include').
with_content(/2001:db8::\/32/)
}
end

describe 'passing something other than an array to $allow_transfer' do
let(:params) {{ :allow_transfer => '127.0.0.1' }}
it { should raise_error(Puppet::Error, /is not an Array/) }
Expand Down
7 changes: 7 additions & 0 deletions templates/zone.erb
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,12 @@ type <%= @zone_type %>;
<% end -%>
};
<% end -%>
<% if @allow_query.size != 0 %>
allow-query {
<% @allow_query.each do |ip| -%>
<%= ip %>;
<% end -%>
};
<% end -%>

};
3 changes: 2 additions & 1 deletion tests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
soa => 'ns1.example.com',
soa_email => 'admin.example.com',
nameservers => [ 'ns1' ],
allow_transfer => [ '192.0.2.0', '2001:db8::/32' ]
allow_transfer => [ '192.0.2.0', '2001:db8::/32' ],
allow_query => [ '192.168.0.0/16' ],
}

dns::zone { '56.168.192.IN-ADDR.ARPA':
Expand Down