diff options
author | Cédric Jeanneret <cedric.jeanneret@camptocamp.com> | 2010-11-08 16:15:43 +0100 |
---|---|---|
committer | Cédric Jeanneret <cedric.jeanneret@camptocamp.com> | 2010-11-15 14:21:11 +0100 |
commit | e0f517634bb58ec8e9f396ff489eb8a9efc73ee0 (patch) | |
tree | be170e0483c52b6bd36a085a957f20ea30975482 | |
download | puppet-bind-e0f517634bb58ec8e9f396ff489eb8a9efc73ee0.tar.gz puppet-bind-e0f517634bb58ec8e9f396ff489eb8a9efc73ee0.tar.bz2 |
(bind) initial import
Doc will be added later.
-rw-r--r-- | files/empty/.placeholder | 0 | ||||
-rw-r--r-- | manifests/classes/bind-base.pp | 23 | ||||
-rw-r--r-- | manifests/classes/bind-debian.pp | 5 | ||||
-rw-r--r-- | manifests/classes/bind.pp | 6 | ||||
-rw-r--r-- | manifests/definitions/bind-a.pp | 15 | ||||
-rw-r--r-- | manifests/definitions/bind-aaaa.pp | 16 | ||||
-rw-r--r-- | manifests/definitions/bind-cname.pp | 15 | ||||
-rw-r--r-- | manifests/definitions/bind-mx.pp | 16 | ||||
-rw-r--r-- | manifests/definitions/bind-ns.pp | 15 | ||||
-rw-r--r-- | manifests/definitions/bind-record.pp | 14 | ||||
-rw-r--r-- | manifests/definitions/bind-zone.pp | 58 | ||||
-rw-r--r-- | manifests/init.pp | 2 | ||||
-rw-r--r-- | templates/default-record.erb | 6 | ||||
-rw-r--r-- | templates/mx-record.erb | 5 | ||||
-rw-r--r-- | templates/zone-header.erb | 10 | ||||
-rw-r--r-- | templates/zone-master.erb | 12 | ||||
-rw-r--r-- | templates/zone-slave.erb | 7 |
17 files changed, 225 insertions, 0 deletions
diff --git a/files/empty/.placeholder b/files/empty/.placeholder new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/files/empty/.placeholder diff --git a/manifests/classes/bind-base.pp b/manifests/classes/bind-base.pp new file mode 100644 index 0000000..b31189e --- /dev/null +++ b/manifests/classes/bind-base.pp @@ -0,0 +1,23 @@ +class bind::base { + package {"bind9": + ensure => present, + } + + service {"bind9": + ensure => running, + enable => true, + require => Package["bind9"], + } + + file {["/etc/bind/pri", "/etc/bind/zones"]: + ensure => directory, + owner => root, + group => root, + mode => 0755, + require => Package["bind9"], + purge => true, + force => true, + recurse => true, + source => "puppet:///modules/bind/empty", + } +} diff --git a/manifests/classes/bind-debian.pp b/manifests/classes/bind-debian.pp new file mode 100644 index 0000000..f998a80 --- /dev/null +++ b/manifests/classes/bind-debian.pp @@ -0,0 +1,5 @@ +class bind::debian inherits bind::base { + Service["bind9"] { + pattern => "/usr/sbin/named", + } +} diff --git a/manifests/classes/bind.pp b/manifests/classes/bind.pp new file mode 100644 index 0000000..dcede05 --- /dev/null +++ b/manifests/classes/bind.pp @@ -0,0 +1,6 @@ +class bind { + case $operatingsystem { + "Debian": { include bind::debian } + default: { fail "Unknown $operatingsystem" } + } +} diff --git a/manifests/definitions/bind-a.pp b/manifests/definitions/bind-a.pp new file mode 100644 index 0000000..37153b8 --- /dev/null +++ b/manifests/definitions/bind-a.pp @@ -0,0 +1,15 @@ +define bind::a($ensure=present, + $zone, + $owner, + $host, + $ttl=false) { + + bind::record {$name: + ensure => $ensure, + zone => $zone, + owner => $owner, + host => $host, + ttl => $ttl, + record_type => 'A', + } +} diff --git a/manifests/definitions/bind-aaaa.pp b/manifests/definitions/bind-aaaa.pp new file mode 100644 index 0000000..a20a58c --- /dev/null +++ b/manifests/definitions/bind-aaaa.pp @@ -0,0 +1,16 @@ +define bind::aaaa($ensure=present, + $zone, + $owner, + $host, + $ttl=false) { + + bind::record {$name: + ensure => $ensure, + zone => $zone, + owner => $owner, + host => $host, + ttl => $ttl, + record_type => 'AAAA', + } + +} diff --git a/manifests/definitions/bind-cname.pp b/manifests/definitions/bind-cname.pp new file mode 100644 index 0000000..e166738 --- /dev/null +++ b/manifests/definitions/bind-cname.pp @@ -0,0 +1,15 @@ +define bind::cname($ensure=present, + $zone, + $owner, + $host, + $ttl=false) { + + bind::record {$name: + ensure => $ensure, + zone => $zone, + owner => $owner, + host => $host, + ttl => $ttl, + record_type => 'CNAME', + } +} diff --git a/manifests/definitions/bind-mx.pp b/manifests/definitions/bind-mx.pp new file mode 100644 index 0000000..7eb63d0 --- /dev/null +++ b/manifests/definitions/bind-mx.pp @@ -0,0 +1,16 @@ +define bind::mx($ensure=present, + $zone, + $owner, + $priority, + $host, + $ttl=false) { + + common::concatfilepart{"bind.${name}": + file => "/etc/bind/pri/${zone}", + ensure => $ensure, + notify => Service["bind9"], + content => template("bind/mx-record.erb"), + require => Bind::Zone[$zone], + } +} + diff --git a/manifests/definitions/bind-ns.pp b/manifests/definitions/bind-ns.pp new file mode 100644 index 0000000..9919f53 --- /dev/null +++ b/manifests/definitions/bind-ns.pp @@ -0,0 +1,15 @@ +define bind::ns($ensure=present, + $zone, + $owner, + $host, + $ttl=false) { + + bind::record {$name: + ensure => $ensure, + zone => $zone, + owner => $owner, + host => $host, + ttl => $ttl, + record_type => 'NS', + } +} diff --git a/manifests/definitions/bind-record.pp b/manifests/definitions/bind-record.pp new file mode 100644 index 0000000..5e0cf6f --- /dev/null +++ b/manifests/definitions/bind-record.pp @@ -0,0 +1,14 @@ +define bind::record($ensure=present, + $zone, + $owner, + $host, + $record_type, + $record_class='IN', + $ttl=false) { + + common::concatfilepart {"${zone}.${record_type}.${name}": + ensure => $ensure, + file => "/etc/bind/pri/${zone}.conf", + content => template("bind/default-record.erb"), + } +} diff --git a/manifests/definitions/bind-zone.pp b/manifests/definitions/bind-zone.pp new file mode 100644 index 0000000..137bcd8 --- /dev/null +++ b/manifests/definitions/bind-zone.pp @@ -0,0 +1,58 @@ +define bind::zone($ensure=present, + $is_slave=false, + $zone_ttl=false, + $zone_contact=false, + $zone_serial=false, + $zone_refresh="3h", + $zone_retry="1h", + $zone_expiracy="1w", + $zone_ns=false, + $zone_xfers=false, + $zone_masters=false) { + + common::concatfilepart {"bind.zones.${name}": + ensure => $ensure, + notify => Service["bind9"], + file => "/etc/bind/zones/${name}.conf", + } + + common::concatfilepart {"named.local.zone.${name}": + ensure => $ensure, + notify => Service["bind9"], + file => "/etc/bind/named.conf.local", + content => "include \"/etc/bind/zones/${name}.conf\";\n", + } + + if $is_slave { + if !$zone_masters { + fail "No master defined for ${name}!" + } + Common::Concatfilepart["bind.zones.${name}"] { + content => template("bind/zone-slave.erb"), + } +## END of slave + } else { + if !$zone_contact { + fail "No contact defined for ${name}!" + } + if !$zone_ns { + fail "No ns defined for ${name}!" + } + if !$zone_serial { + fail "No serial defined for ${name}!" + } + if !$zone_ttl { + fail "No ttl defined for ${name}!" + } + + Common::Concatfilepart["bind.zones.${name}"] { + content => template("bind/zone-master.erb"), + } + + common::concatfilepart {"bind.00.${name}": + ensure => $ensure, + file => "/etc/bind/pri/${name}.conf", + content => template("bind/zone-header.erb"), + } + } +} diff --git a/manifests/init.pp b/manifests/init.pp new file mode 100644 index 0000000..6cc1969 --- /dev/null +++ b/manifests/init.pp @@ -0,0 +1,2 @@ +import "classes/*.pp" +import "definitions/*.pp" diff --git a/templates/default-record.erb b/templates/default-record.erb new file mode 100644 index 0000000..64aa056 --- /dev/null +++ b/templates/default-record.erb @@ -0,0 +1,6 @@ +<% if ttl -%> +<%=owner%> <%=ttl%> <%=record_class%> <%=record_type%> <%=host%> +<% else -%> +<%=owner%> <%=record_class%> <%=record_type%> <%=host%> +<% end -%> + diff --git a/templates/mx-record.erb b/templates/mx-record.erb new file mode 100644 index 0000000..a8ec89d --- /dev/null +++ b/templates/mx-record.erb @@ -0,0 +1,5 @@ +<% if ttl -%> +<%=owner%> <%=ttl%> IN MX <%=priority%> <%=host%> +<% else -%> +<%=owner%> IN MX <%=priority%> <%=host%> +<% end -%> diff --git a/templates/zone-header.erb b/templates/zone-header.erb new file mode 100644 index 0000000..da93b31 --- /dev/null +++ b/templates/zone-header.erb @@ -0,0 +1,10 @@ +; File managed by puppet +$TTL <%=zone_ttl%> +@ IN SOA <%=name%>. <%=zone_contact%>. ( + <%=zone_serial%> ; serial + <%=zone_refresh%> ; refresh + <%=zone_retry%> ; retry + <%=zone_expiracy%>; expiracy + <%=zone_ttl%> ) ; TTL + IN NS <%=zone_ns%>. + diff --git a/templates/zone-master.erb b/templates/zone-master.erb new file mode 100644 index 0000000..d9e88fd --- /dev/null +++ b/templates/zone-master.erb @@ -0,0 +1,12 @@ +# File managed by puppet +zone "<%=name%>" IN { + type master; + file "/etc/bind/pri/<%=name%>.conf"; +<% if zone_xfers and not zone_xfers.empty? -%> + allow-transfer { <%= zone_xfers.collect! {|i| "#{i}" }.join('; ') -%> }; +<% else -%> + allow-transfer { none; }; +<% end -%> + allow-query { any; }; + notify yes; +}; diff --git a/templates/zone-slave.erb b/templates/zone-slave.erb new file mode 100644 index 0000000..02364c1 --- /dev/null +++ b/templates/zone-slave.erb @@ -0,0 +1,7 @@ +# File managed by puppet +zone <%=name%> IN { + type slave; + masters { <%= masters.collect! {|i| "#{i}" }.join('; ') -%> }; + allow-query { any; }; + notify yes; +} |