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 reverse => reverse option to dns::zone #162

Merged
merged 1 commit into from May 15, 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
3 changes: 2 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,14 @@ PLATFORMS
DEPENDENCIES
beaker (> 2.0.0)
beaker-rspec (>= 5.1.0)
json
pry
puppet (~> 3.7.0)
puppet-blacksmith
puppet-lint
puppet-syntax
puppetlabs_spec_helper
rake
rake (< 11.0.0)
rspec (< 3.2.0)
rspec-core (= 3.1.7)
rspec-puppet (~> 2.1)
Expand Down
8 changes: 6 additions & 2 deletions manifests/zone.pp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@
#
# [*reverse*]
# If `true`, the zone will have `.in-addr.arpa` appended to it.
# If set to the string `reverse`, the `.`-separated components of
# the zone will be reversed, and then have `.in-addr.arpa` appended
# to it.
# Defaults to `false`.
#
# [*slave_masters*]
Expand Down Expand Up @@ -172,8 +175,9 @@
}

$zone = $reverse ? {
true => "${name}.in-addr.arpa",
default => $name
'reverse' => join(reverse(split("arpa.in-addr.${name}", '\.')), '.'),
true => "${name}.in-addr.arpa",
default => $name
}

validate_string($zone_type)
Expand Down
18 changes: 18 additions & 0 deletions spec/defines/dns__zone_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -293,5 +293,23 @@
it { should contain_concat__fragment('named.conf.local.test.com.include').with_content(/8\.8\.8\.8;/) }
end

context 'passing true to reverse' do
let(:title) { '10.23.45' }
let :params do
{ :reverse => true }
end
it { should contain_concat__fragment('named.conf.local.10.23.45.include').with_content(/zone "10\.23\.45\.in-addr\.arpa"/) }
it { should contain_concat__fragment('db.10.23.45.soa').with_content(/\$ORIGIN\s+10\.23\.45\.in-addr\.arpa\./) }
end

context 'passing reverse to reverse' do
let(:title) { '10.23.45' }
let :params do
{ :reverse => 'reverse' }
end
it { should contain_concat__fragment('named.conf.local.10.23.45.include').with_content(/zone "45\.23\.10\.in-addr\.arpa"/) }
it { should contain_concat__fragment('db.10.23.45.soa').with_content(/\$ORIGIN\s+45\.23\.10\.in-addr\.arpa\./) }
end

end