Skip to content

Commit

Permalink
Merge pull request #99 from jearls/only-update-master-zone-files
Browse files Browse the repository at this point in the history
zone files should only be created or modified for master zones
  • Loading branch information
solarkennedy committed Apr 14, 2015
2 parents 968851d + a715244 commit 17dfb7e
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 2 deletions.
8 changes: 7 additions & 1 deletion manifests/zone.pp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
file { $zone_file:
ensure => absent,
}
} else {
} elsif $zone_type == 'master' {
# Zone Database

# Create "fake" zone file without zone-serial
Expand Down Expand Up @@ -74,6 +74,12 @@
require => Class['dns::server::install'],
notify => Class['dns::server::service'],
}
} else {
# For any zone file that is not a master zone, we should make sure
# we don't have a staging file
concat { $zone_file_stage:
ensure => absent
}
}

# Include Zone in named.conf.local
Expand Down
82 changes: 81 additions & 1 deletion spec/defines/dns__zone_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
with_content(/forward/)
end
end

context 'with a forward zone' do
let :params do
{ :allow_transfer => ['123.123.123.123'],
Expand All @@ -103,7 +104,7 @@
end
it 'should not have allow_tranfer entry' do
should_not contain_concat__fragment('named.conf.local.test.com.include').
with_content(/allow_transfer/)
with_content(/allow-transfer/)
end
it 'should not have file entry' do
should_not contain_concat__fragment('named.conf.local.test.com.include').
Expand All @@ -117,7 +118,86 @@
should contain_concat__fragment('named.conf.local.test.com.include').
with_content(/forwarders/)
end
it 'should have an "absent" zone file concat' do
should contain_concat('/etc/bind/zones/db.test.com.stage').with({
:ensure => "absent"
})
end
end

context 'with a slave zone' do
let :params do
{ :slave_masters => ['123.123.123.123'],
:zone_type => 'slave'
}
end
it 'should have a type slave entry' do
should contain_concat__fragment('named.conf.local.test.com.include').
with_content(/type slave/)
end
it 'should have file entry' do
should contain_concat__fragment('named.conf.local.test.com.include').
with_content(/file/)
end
it 'should have masters entry' do
should contain_concat__fragment('named.conf.local.test.com.include').
with_content(/masters/)
end
it 'should not have allow_tranfer entry' do
should_not contain_concat__fragment('named.conf.local.test.com.include').
with_content(/allow-transfer/)
end
it 'should not have any forward information' do
should_not contain_concat__fragment('named.conf.local.test.com.include').
with_content(/forward/)
end
it 'should have an "absent" zone file concat' do
should contain_concat('/etc/bind/zones/db.test.com.stage').with({
:ensure => "absent"
})
end
end

context 'with a master zone' do
let :params do
{ :allow_transfer => ['8.8.8.8','8.8.4.4'],
:allow_forwarder => ['8.8.8.8', '208.67.222.222'],
:forward_policy => 'only',
:zone_type => 'master'
}
end
it 'should have a type master entry' do
should contain_concat__fragment('named.conf.local.test.com.include').
with_content(/type master/)
end
it 'should have file entry' do
should contain_concat__fragment('named.conf.local.test.com.include').
with_content(/file/)
end
it 'should not have masters entry' do
should_not contain_concat__fragment('named.conf.local.test.com.include').
with_content(/masters/)
end
it 'should have allow_tranfer entry' do
should contain_concat__fragment('named.conf.local.test.com.include').
with_content(/allow-transfer/)
end
it 'should have a forward-policy entry' do
should contain_concat__fragment('named.conf.local.test.com.include').
with_content(/forward /)
end
it 'should have a forwarders entry' do
should contain_concat__fragment('named.conf.local.test.com.include').
with_content(/forwarders/)
end
it 'should have a zone file concat' do
should contain_concat('/etc/bind/zones/db.test.com.stage').with({
:ensure => "present"
})
end
end


end
end

0 comments on commit 17dfb7e

Please sign in to comment.