Skip to content

Commit

Permalink
Merge pull request #143 from code-management/delegation-only-zone
Browse files Browse the repository at this point in the history
Add support for delegation-only zone types.
  • Loading branch information
solarkennedy committed Dec 10, 2015
2 parents 7771114 + afb06ad commit 577cb56
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
13 changes: 10 additions & 3 deletions manifests/zone.pp
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@
#
# [*zone_type*]
# The type of DNS zone being described. Can be one of `master`, `slave`
# (requires *slave_masters* to be set), or `forward` (requires both
# *allow_forwarder* and *forward_policy* to be set). Defaults to
# `master`.
# (requires *slave_masters* to be set), `delegation-only`, or `forward`
# (requires both *allow_forwarder* and *forward_policy* to be set).
# Defaults to `master`.
#
define dns::zone (
$soa = $::fqdn,
Expand Down Expand Up @@ -170,6 +170,13 @@
default => $name
}

validate_string($zone_type)
$valid_zone_type_array = ['master', 'slave', 'forward', 'delegation-only']
if !member($valid_zone_type_array, $zone_type) {
$valid_zone_type_array_str = join($valid_zone_type_array, ',')
fail("The zone_type must be one of [${valid_zone_type_array}]")
}

$zone_file = "${dns::server::params::data_dir}/db.${name}"
$zone_file_stage = "${zone_file}.stage"

Expand Down
12 changes: 12 additions & 0 deletions spec/defines/dns__zone_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@
end
end

context 'with a delegation-only zone' do
let :params do
{ :zone_type => 'delegation-only'
}
end
it 'should only have a type delegation-only entry' do
should contain_concat__fragment('named.conf.local.test.com.include').
with_content(/zone \"test.com\" \{\s*type delegation-only;\s*\}/)
end
end


context 'with a forward zone' do
let :params do
{ :allow_transfer => ['123.123.123.123'],
Expand Down
2 changes: 1 addition & 1 deletion templates/zone.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type <%= @zone_type %>;
<%- end -%>
};
<% end -%>
<% if @zone_type != 'forward' -%>
<% if (@zone_type != 'forward') && (@zone_type != 'delegation-only')-%>
file "<%= @zone_file %>";
<% end -%>
<% if @zone_type == 'slave' -%>
Expand Down

0 comments on commit 577cb56

Please sign in to comment.