Skip to content
Open
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
30 changes: 30 additions & 0 deletions manifests/include.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
define bind::include (
$zone,
$ensure = present,
$file = '',
$inline_origin = true,
$order = 10,
$origin = '',
){

validate_string($zone)
validate_re($ensure, ['present', 'absent'])
validate_string($file)
validate_bool($inline_origin)
validate_string($origin)

if ($file != '') {
$_file = $file
} else {
$_file = $name
}

concat::fragment {"${zone}.include.${name}":
ensure => $ensure,
content => template('bind/include.erb'),
notify => Service['bind9'],
order => $order,
require => File[$_file],
target => "${bind::params::pri_directory}/${zone}.conf",
}
}
73 changes: 73 additions & 0 deletions spec/acceptance/bind_include_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
require 'spec_helper_acceptance'

describe 'bind' do

let(:serial) { '2016021209' }

context "With a call to bind::include" do

it "should run and start bind" do
pp = <<-EOS
class {'::bind':
}
::bind::zone {'my-zone.tld':
ensure => present,
zone_contact => 'contact.my-zone.tld',
zone_ns => [
'ns0.my-zone.tld',
'ns1.my-zone.tld',
],
zone_serial => '#{serial}',
zone_ttl => '18600',
}
file {'/tmp/bind-include.inc':
ensure => file,
content => 'include IN CNAME ns0',
}
::bind::a {'A records':
ensure => present,
zone => 'my-zone.tld',
ptr => false,
hash_data => {
'@' => { owner => '192.168.10.1', },
'test' => { owner => '192.168.10.2', },
'ns0' => { owner => '192.168.10.252', },
'ns1' => { owner => '192.168.10.253', },
}
}
::bind::include {'empty include':
ensure => present,
file => '/tmp/bind-include.inc',
zone => 'my-zone.tld',
}
case $::osfamily {
'Debian': {
package {'dnsutils': }
}
'RedHat': {
package {'bind-utils': }
}
}
EOS

apply_manifest(pp, :cat_failures => true)
apply_manifest(pp, :catch_changes => true)
end

describe port("53") {
it {
should be_listening.with('tcp')
should be_listening.with('udp')
}
}

describe command("host -4 ns1.my-zone.tld localhost") do
its(:stdout) {should match /ns1.my-zone.tld has address 192.168.10.253/}
end
describe command("host -4 include.my-zone.tld localhost") do
its(:stdout) {should match /include.my-zone.tld is an alias for ns0.my-zone.tld./}
end


end
end
11 changes: 11 additions & 0 deletions templates/include.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
; Bind::Include['<%=@name%>']
<% if @origin != ''%>
<% if @inline_origin -%>
$INCLUDE <%=@origin%> <%=@_file%>
<% else -%>
$ORIGIN <%=@origin%>
$INCLUDE <%=@_file%>
<% end -%>
<% else -%>
$INCLUDE <%= @_file %>
<% end -%>