From 61452bec75976590a0293870d410ed0d3c80f843 Mon Sep 17 00:00:00 2001 From: Marc Fournier Date: Tue, 15 Nov 2011 13:13:29 +0100 Subject: file renaming to be compliant with recommended module structure. --- manifests/a.pp | 27 +++++++++++ manifests/aaaa.pp | 28 ++++++++++++ manifests/base.pp | 32 +++++++++++++ manifests/classes/bind-base.pp | 32 ------------- manifests/classes/bind-debian.pp | 14 ------ manifests/classes/bind.pp | 54 ---------------------- manifests/cname.pp | 27 +++++++++++ manifests/debian.pp | 14 ++++++ manifests/definitions/bind-a.pp | 27 ----------- manifests/definitions/bind-aaaa.pp | 28 ------------ manifests/definitions/bind-cname.pp | 27 ----------- manifests/definitions/bind-mx.pp | 35 -------------- manifests/definitions/bind-ns.pp | 27 ----------- manifests/definitions/bind-record.pp | 35 -------------- manifests/definitions/bind-zone.pp | 88 ------------------------------------ manifests/init.pp | 56 ++++++++++++++++++++++- manifests/mx.pp | 35 ++++++++++++++ manifests/ns.pp | 27 +++++++++++ manifests/record.pp | 35 ++++++++++++++ manifests/zone.pp | 88 ++++++++++++++++++++++++++++++++++++ 20 files changed, 367 insertions(+), 369 deletions(-) create mode 100644 manifests/a.pp create mode 100644 manifests/aaaa.pp create mode 100644 manifests/base.pp delete mode 100644 manifests/classes/bind-base.pp delete mode 100644 manifests/classes/bind-debian.pp delete mode 100644 manifests/classes/bind.pp create mode 100644 manifests/cname.pp create mode 100644 manifests/debian.pp delete mode 100644 manifests/definitions/bind-a.pp delete mode 100644 manifests/definitions/bind-aaaa.pp delete mode 100644 manifests/definitions/bind-cname.pp delete mode 100644 manifests/definitions/bind-mx.pp delete mode 100644 manifests/definitions/bind-ns.pp delete mode 100644 manifests/definitions/bind-record.pp delete mode 100644 manifests/definitions/bind-zone.pp create mode 100644 manifests/mx.pp create mode 100644 manifests/ns.pp create mode 100644 manifests/record.pp create mode 100644 manifests/zone.pp diff --git a/manifests/a.pp b/manifests/a.pp new file mode 100644 index 0000000..3f30187 --- /dev/null +++ b/manifests/a.pp @@ -0,0 +1,27 @@ +/* + += Definition: bind::a +Creates an IPv4 record. + +Arguments: + *$zone*: Bind::Zone name + *$owner*: owner of the Resource Record + *$host*: target of the Resource Record + *$ttl*: Time to Live for the Resource Record. Optional. + +*/ +define bind::a($ensure=present, + $zone, + $owner=false, + $host, + $ttl=false) { + + bind::record {$name: + ensure => $ensure, + zone => $zone, + owner => $owner, + host => $host, + ttl => $ttl, + record_type => 'A', + } +} diff --git a/manifests/aaaa.pp b/manifests/aaaa.pp new file mode 100644 index 0000000..80291c2 --- /dev/null +++ b/manifests/aaaa.pp @@ -0,0 +1,28 @@ +/* + += Definition: bind::aaaa +Creates an IPv6 AAAA record. + +Arguments: + *$zone*: Bind::Zone name + *$owner*: owner of the Resource Record + *$host*: target of the Resource Record + *$ttl*: Time to Live for the Resource Record. Optional. + +*/ +define bind::aaaa($ensure=present, + $zone, + $owner=false, + $host, + $ttl=false) { + + bind::record {$name: + ensure => $ensure, + zone => $zone, + owner => $owner, + host => $host, + ttl => $ttl, + record_type => 'AAAA', + } + +} diff --git a/manifests/base.pp b/manifests/base.pp new file mode 100644 index 0000000..c442085 --- /dev/null +++ b/manifests/base.pp @@ -0,0 +1,32 @@ +/* + += Class: bind::base + +Declares some basic resources. +You should NOT include this class as is, as it won't work at all! +Please refer to Class["bind"]. + +*/ +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-base.pp b/manifests/classes/bind-base.pp deleted file mode 100644 index c442085..0000000 --- a/manifests/classes/bind-base.pp +++ /dev/null @@ -1,32 +0,0 @@ -/* - -= Class: bind::base - -Declares some basic resources. -You should NOT include this class as is, as it won't work at all! -Please refer to Class["bind"]. - -*/ -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 deleted file mode 100644 index 7b752ae..0000000 --- a/manifests/classes/bind-debian.pp +++ /dev/null @@ -1,14 +0,0 @@ -/* - -= Class: bind::debian -Special debian class - inherits from bind::base - -You should not include this class - please refer to Class["bind"] - -*/ -class bind::debian inherits bind::base { - Service["bind9"] { - pattern => "/usr/sbin/named", - restart => "/etc/init.d/bind9 reload", - } -} diff --git a/manifests/classes/bind.pp b/manifests/classes/bind.pp deleted file mode 100644 index d9af708..0000000 --- a/manifests/classes/bind.pp +++ /dev/null @@ -1,54 +0,0 @@ -/* - -= Class: bind -Include this class to install bind9 server on your node. - -Requires: -- module common (git://github.com/camptocamp/puppet-common.git) - -Bind documentation: -http://www.bind9.net/manuals - -Limitations: -This modules is valid for Bind 9.7.1 (squeeze version). -For 9.7.2, it will be really limited (no view nor ACL support). - - -Example: - -node "ns1.domain.ltd" { - include bind - bind::zone {"domain.ltd": - ensure => present, - zone_contact => "contact.domain.ltd", - zone_ns => $fqdn, - zone_serial => "2010110804", - zone_ttl => "604800", - } - - bind::a {"ns $fqdn": - zone => "domain.ltd", - owner => "${fqdn}.", - host => $ipaddress, - } - - bind::a {"mail.domain.ltd": - zone => "domain.ltd", - owner => "mail", - host => "6.6.6.6", - } - - bind::mx {"mx1": - zone => "domain.ltd", - owner => "@", - priority => 1, - host => "mail.domain.ltd", - } -} -*/ -class bind { - case $operatingsystem { - "Debian","Ubuntu": { include bind::debian } - default: { fail "Unknown $operatingsystem" } - } -} diff --git a/manifests/cname.pp b/manifests/cname.pp new file mode 100644 index 0000000..c8baeec --- /dev/null +++ b/manifests/cname.pp @@ -0,0 +1,27 @@ +/* + += Definition: bind::cname +Creates a CNAME record. + +Arguments: + *$zone*: Bind::Zone name + *$owner*: owner of the Resource Record + *$host*: target of the Resource Record + *$ttl*: Time to Live for the Resource Record. Optional. + +*/ +define bind::cname($ensure=present, + $zone, + $owner=false, + $host, + $ttl=false) { + + bind::record {$name: + ensure => $ensure, + zone => $zone, + owner => $owner, + host => $host, + ttl => $ttl, + record_type => 'CNAME', + } +} diff --git a/manifests/debian.pp b/manifests/debian.pp new file mode 100644 index 0000000..7b752ae --- /dev/null +++ b/manifests/debian.pp @@ -0,0 +1,14 @@ +/* + += Class: bind::debian +Special debian class - inherits from bind::base + +You should not include this class - please refer to Class["bind"] + +*/ +class bind::debian inherits bind::base { + Service["bind9"] { + pattern => "/usr/sbin/named", + restart => "/etc/init.d/bind9 reload", + } +} diff --git a/manifests/definitions/bind-a.pp b/manifests/definitions/bind-a.pp deleted file mode 100644 index 3f30187..0000000 --- a/manifests/definitions/bind-a.pp +++ /dev/null @@ -1,27 +0,0 @@ -/* - -= Definition: bind::a -Creates an IPv4 record. - -Arguments: - *$zone*: Bind::Zone name - *$owner*: owner of the Resource Record - *$host*: target of the Resource Record - *$ttl*: Time to Live for the Resource Record. Optional. - -*/ -define bind::a($ensure=present, - $zone, - $owner=false, - $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 deleted file mode 100644 index 80291c2..0000000 --- a/manifests/definitions/bind-aaaa.pp +++ /dev/null @@ -1,28 +0,0 @@ -/* - -= Definition: bind::aaaa -Creates an IPv6 AAAA record. - -Arguments: - *$zone*: Bind::Zone name - *$owner*: owner of the Resource Record - *$host*: target of the Resource Record - *$ttl*: Time to Live for the Resource Record. Optional. - -*/ -define bind::aaaa($ensure=present, - $zone, - $owner=false, - $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 deleted file mode 100644 index c8baeec..0000000 --- a/manifests/definitions/bind-cname.pp +++ /dev/null @@ -1,27 +0,0 @@ -/* - -= Definition: bind::cname -Creates a CNAME record. - -Arguments: - *$zone*: Bind::Zone name - *$owner*: owner of the Resource Record - *$host*: target of the Resource Record - *$ttl*: Time to Live for the Resource Record. Optional. - -*/ -define bind::cname($ensure=present, - $zone, - $owner=false, - $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 deleted file mode 100644 index 84a2b9f..0000000 --- a/manifests/definitions/bind-mx.pp +++ /dev/null @@ -1,35 +0,0 @@ -/* - -= Definition: bind::mx -Creates an MX record. - -Arguments: - *$zone*: Bind::Zone name - *$owner*: owner of the Resource Record - *$priority*: MX record priority - *$host*: target of the Resource Record - *$ttl*: Time to Live for the Resource Record. Optional. - -*/ -define bind::mx($ensure=present, - $zone, - $owner=false, - $priority, - $host, - $ttl=false) { - - if $owner { - $_owner = $owner - } else { - $_owner = $name - } - - common::concatfilepart{"bind.${name}": - file => "/etc/bind/pri/${zone}", - ensure => $ensure, - notify => Service["bind9"], - content => template("bind/mx-record.erb"), - require => [Bind::Zone[$zone], Bind::A[$host]], - } -} - diff --git a/manifests/definitions/bind-ns.pp b/manifests/definitions/bind-ns.pp deleted file mode 100644 index 3d07aea..0000000 --- a/manifests/definitions/bind-ns.pp +++ /dev/null @@ -1,27 +0,0 @@ -/* - -= Definition: bind::ns -Creates an NS record. - -Arguments: - *$zone*: Bind::Zone name - *$owner*: owner of the Resource Record - *$host*: target of the Resource Record - *$ttl*: Time to Live for the Resource Record. Optional. - -*/ -define bind::ns($ensure=present, - $zone, - $owner=false, - $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 deleted file mode 100644 index d551d60..0000000 --- a/manifests/definitions/bind-record.pp +++ /dev/null @@ -1,35 +0,0 @@ -/* - -= Definition: bind::record -Helper to create any record you want (but NOT MX, please refer to Bind::Mx) - -Arguments: - *$zone*: Bind::Zone name - *$owner*: owner of the Resource Record - *$host*: target of the Resource Record - *$record_type°: resource record type - *$record_class*: resource record class. Default "IN". - *$ttl*: Time to Live for the Resource Record. Optional. - -*/ -define bind::record($ensure=present, - $zone, - $owner=false, - $host, - $record_type, - $record_class='IN', - $ttl=false) { - - if $owner { - $_owner = $owner - } else { - $_owner = $name - } - - common::concatfilepart {"${zone}.${record_type}.${name}": - ensure => $ensure, - file => "/etc/bind/pri/${zone}.conf", - content => template("bind/default-record.erb"), - notify => Service["bind9"], - } -} diff --git a/manifests/definitions/bind-zone.pp b/manifests/definitions/bind-zone.pp deleted file mode 100644 index 64da5da..0000000 --- a/manifests/definitions/bind-zone.pp +++ /dev/null @@ -1,88 +0,0 @@ -/* - -= Definition: bind::zone -Creates a valid Bind9 zone. - -Arguments: - *$is_slave*: Boolean. Is your zone a slave or a master? Default false - *$zone_ttl*: Time period. Time to live for your zonefile (master only) - *$zone_contact*: Valid contact record (master only) - *$zone_serial*: Integer. Zone serial (master only) - *$zone_refresh*: Time period. Time between each slave refresh (master only) - *$zone_retry*: Time period. Time between each slave retry (master only) - *$zone_expiracy*: Time period. Slave expiracy time (master only) - *$zone_ns*: Valid NS for this zone (master only) - *$zone_xfers*: IPs. Valid xfers for zone (master only) - *$zone_masters*: IPs. Valid master for this zone (slave only) - -*/ -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", - require => Package["bind9"], - } - - 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", - require => Package["bind9"], - } - - 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"), - require => Package["bind9"], - } - - file {"/etc/bind/pri/${name}.conf.d": - ensure => directory, - mode => 0700, - purge => true, - recurse => true, - backup => false, - force => true, - } - } -} diff --git a/manifests/init.pp b/manifests/init.pp index 6cc1969..d9af708 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,2 +1,54 @@ -import "classes/*.pp" -import "definitions/*.pp" +/* + += Class: bind +Include this class to install bind9 server on your node. + +Requires: +- module common (git://github.com/camptocamp/puppet-common.git) + +Bind documentation: +http://www.bind9.net/manuals + +Limitations: +This modules is valid for Bind 9.7.1 (squeeze version). +For 9.7.2, it will be really limited (no view nor ACL support). + + +Example: + +node "ns1.domain.ltd" { + include bind + bind::zone {"domain.ltd": + ensure => present, + zone_contact => "contact.domain.ltd", + zone_ns => $fqdn, + zone_serial => "2010110804", + zone_ttl => "604800", + } + + bind::a {"ns $fqdn": + zone => "domain.ltd", + owner => "${fqdn}.", + host => $ipaddress, + } + + bind::a {"mail.domain.ltd": + zone => "domain.ltd", + owner => "mail", + host => "6.6.6.6", + } + + bind::mx {"mx1": + zone => "domain.ltd", + owner => "@", + priority => 1, + host => "mail.domain.ltd", + } +} +*/ +class bind { + case $operatingsystem { + "Debian","Ubuntu": { include bind::debian } + default: { fail "Unknown $operatingsystem" } + } +} diff --git a/manifests/mx.pp b/manifests/mx.pp new file mode 100644 index 0000000..84a2b9f --- /dev/null +++ b/manifests/mx.pp @@ -0,0 +1,35 @@ +/* + += Definition: bind::mx +Creates an MX record. + +Arguments: + *$zone*: Bind::Zone name + *$owner*: owner of the Resource Record + *$priority*: MX record priority + *$host*: target of the Resource Record + *$ttl*: Time to Live for the Resource Record. Optional. + +*/ +define bind::mx($ensure=present, + $zone, + $owner=false, + $priority, + $host, + $ttl=false) { + + if $owner { + $_owner = $owner + } else { + $_owner = $name + } + + common::concatfilepart{"bind.${name}": + file => "/etc/bind/pri/${zone}", + ensure => $ensure, + notify => Service["bind9"], + content => template("bind/mx-record.erb"), + require => [Bind::Zone[$zone], Bind::A[$host]], + } +} + diff --git a/manifests/ns.pp b/manifests/ns.pp new file mode 100644 index 0000000..3d07aea --- /dev/null +++ b/manifests/ns.pp @@ -0,0 +1,27 @@ +/* + += Definition: bind::ns +Creates an NS record. + +Arguments: + *$zone*: Bind::Zone name + *$owner*: owner of the Resource Record + *$host*: target of the Resource Record + *$ttl*: Time to Live for the Resource Record. Optional. + +*/ +define bind::ns($ensure=present, + $zone, + $owner=false, + $host, + $ttl=false) { + + bind::record {$name: + ensure => $ensure, + zone => $zone, + owner => $owner, + host => $host, + ttl => $ttl, + record_type => 'NS', + } +} diff --git a/manifests/record.pp b/manifests/record.pp new file mode 100644 index 0000000..d551d60 --- /dev/null +++ b/manifests/record.pp @@ -0,0 +1,35 @@ +/* + += Definition: bind::record +Helper to create any record you want (but NOT MX, please refer to Bind::Mx) + +Arguments: + *$zone*: Bind::Zone name + *$owner*: owner of the Resource Record + *$host*: target of the Resource Record + *$record_type°: resource record type + *$record_class*: resource record class. Default "IN". + *$ttl*: Time to Live for the Resource Record. Optional. + +*/ +define bind::record($ensure=present, + $zone, + $owner=false, + $host, + $record_type, + $record_class='IN', + $ttl=false) { + + if $owner { + $_owner = $owner + } else { + $_owner = $name + } + + common::concatfilepart {"${zone}.${record_type}.${name}": + ensure => $ensure, + file => "/etc/bind/pri/${zone}.conf", + content => template("bind/default-record.erb"), + notify => Service["bind9"], + } +} diff --git a/manifests/zone.pp b/manifests/zone.pp new file mode 100644 index 0000000..64da5da --- /dev/null +++ b/manifests/zone.pp @@ -0,0 +1,88 @@ +/* + += Definition: bind::zone +Creates a valid Bind9 zone. + +Arguments: + *$is_slave*: Boolean. Is your zone a slave or a master? Default false + *$zone_ttl*: Time period. Time to live for your zonefile (master only) + *$zone_contact*: Valid contact record (master only) + *$zone_serial*: Integer. Zone serial (master only) + *$zone_refresh*: Time period. Time between each slave refresh (master only) + *$zone_retry*: Time period. Time between each slave retry (master only) + *$zone_expiracy*: Time period. Slave expiracy time (master only) + *$zone_ns*: Valid NS for this zone (master only) + *$zone_xfers*: IPs. Valid xfers for zone (master only) + *$zone_masters*: IPs. Valid master for this zone (slave only) + +*/ +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", + require => Package["bind9"], + } + + 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", + require => Package["bind9"], + } + + 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"), + require => Package["bind9"], + } + + file {"/etc/bind/pri/${name}.conf.d": + ensure => directory, + mode => 0700, + purge => true, + recurse => true, + backup => false, + force => true, + } + } +} -- cgit v1.2.3 From 475c28a91221793a029fb81bfbc66c55fcb427a2 Mon Sep 17 00:00:00 2001 From: Raphaël Pinson Date: Tue, 20 Mar 2012 15:38:17 +0100 Subject: Add bind::txt --- manifests/txt.pp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 manifests/txt.pp diff --git a/manifests/txt.pp b/manifests/txt.pp new file mode 100644 index 0000000..31dd189 --- /dev/null +++ b/manifests/txt.pp @@ -0,0 +1,27 @@ +/* + += Definition: bind::txt +Creates an IPv4 record. + +Arguments: + *$zone*: Bind::Zone name + *$owner*: owner of the Resource Record + *$text*: target of the Resource Record + *$ttl*: Time to Live for the Resource Record. Optional. + +*/ +define bind::txt($ensure=present, + $zone, + $owner=false, + $text, + $ttl=false) { + + bind::record {$name: + ensure => $ensure, + zone => $zone, + owner => $owner, + host => $text, + ttl => $ttl, + record_type => 'TXT', + } +} -- cgit v1.2.3 From ea7b48f76a9fbb03ee1229c168748e93f5d78984 Mon Sep 17 00:00:00 2001 From: Raphaël Pinson Date: Mon, 26 Mar 2012 12:20:39 +0200 Subject: Add bind::ptr --- manifests/ptr.pp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 manifests/ptr.pp diff --git a/manifests/ptr.pp b/manifests/ptr.pp new file mode 100644 index 0000000..1904c5d --- /dev/null +++ b/manifests/ptr.pp @@ -0,0 +1,27 @@ +/* + += Definition: bind::ptr +Creates a PTR record. + +Arguments: + *$zone*: Bind::Zone name + *$owner*: number of the Resource Record + *$host*: target of the Resource Record + *$ttl*: Time to Live for the Resource Record. Optional. + +*/ +define bind::ptr($ensure=present, + $zone, + $owner=false, + $host, + $ttl=false) { + + bind::record {$name: + ensure => $ensure, + zone => $zone, + owner => $owner, + host => $host, + ttl => $ttl, + record_type => 'PTR', + } +} -- cgit v1.2.3 From 60515f980483225bf48c728bf30cda84a90a911a Mon Sep 17 00:00:00 2001 From: Raphaël Pinson Date: Mon, 26 Mar 2012 15:34:28 +0200 Subject: Create PTR records from A records --- manifests/a.pp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/manifests/a.pp b/manifests/a.pp index 3f30187..f2e8bca 100644 --- a/manifests/a.pp +++ b/manifests/a.pp @@ -8,13 +8,15 @@ Arguments: *$owner*: owner of the Resource Record *$host*: target of the Resource Record *$ttl*: Time to Live for the Resource Record. Optional. + *$ptr*: create the corresponding ptr record (default=true) */ define bind::a($ensure=present, $zone, $owner=false, $host, - $ttl=false) { + $ttl=false, + $ptr=true) { bind::record {$name: ensure => $ensure, @@ -24,4 +26,17 @@ define bind::a($ensure=present, ttl => $ttl, record_type => 'A', } + + if $ptr { + $subnet = inline_template(<%= host.split('.')[0,3].join('.') %>) + $number = inline_template(<%= host.split('.')[3] %>) + $fqdn = $owner + + bind::ptr { + ensure => $ensure, + zone => $subnet, + owner => $number, + host => $fqdn, + ttl => $ttl, + } } -- cgit v1.2.3 From b15c05131ef0b75f1bdf505e3d6504f68a461dc0 Mon Sep 17 00:00:00 2001 From: Raphaël Pinson Date: Mon, 26 Mar 2012 18:59:56 +0200 Subject: Change variable name (don't use $fqdn) --- manifests/a.pp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/manifests/a.pp b/manifests/a.pp index f2e8bca..903315b 100644 --- a/manifests/a.pp +++ b/manifests/a.pp @@ -28,15 +28,15 @@ define bind::a($ensure=present, } if $ptr { - $subnet = inline_template(<%= host.split('.')[0,3].join('.') %>) - $number = inline_template(<%= host.split('.')[3] %>) - $fqdn = $owner + $subnet = inline_template("<%= host.split('.')[0,3].join('.') %>") + $number = inline_template("<%= host.split('.')[3] %>") - bind::ptr { + bind::ptr {$host: ensure => $ensure, zone => $subnet, owner => $number, - host => $fqdn, + host => $owner, ttl => $ttl, } + } } -- cgit v1.2.3 From dee043fb0c19352a3b45419bd5b1695b949cb3b4 Mon Sep 17 00:00:00 2001 From: Raphaël Pinson Date: Wed, 28 Mar 2012 15:19:18 +0200 Subject: Make sure wrk are unique resources, don't activate PTR by default --- manifests/a.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/a.pp b/manifests/a.pp index 903315b..610c473 100644 --- a/manifests/a.pp +++ b/manifests/a.pp @@ -16,7 +16,7 @@ define bind::a($ensure=present, $owner=false, $host, $ttl=false, - $ptr=true) { + $ptr=false) { bind::record {$name: ensure => $ensure, -- cgit v1.2.3 From 5624dabab9690c8628ee403d7489bd8b0e504720 Mon Sep 17 00:00:00 2001 From: Raphaël Pinson Date: Thu, 29 Mar 2012 14:28:09 +0200 Subject: default=false for ptr in a.pp --- manifests/a.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/a.pp b/manifests/a.pp index 610c473..810f931 100644 --- a/manifests/a.pp +++ b/manifests/a.pp @@ -8,7 +8,7 @@ Arguments: *$owner*: owner of the Resource Record *$host*: target of the Resource Record *$ttl*: Time to Live for the Resource Record. Optional. - *$ptr*: create the corresponding ptr record (default=true) + *$ptr*: create the corresponding ptr record (default=false) */ define bind::a($ensure=present, -- cgit v1.2.3 From fa03e03fce3d604eeb90bdf11bf574f3b70845dc Mon Sep 17 00:00:00 2001 From: Raphaël Pinson Date: Thu, 29 Mar 2012 14:58:04 +0200 Subject: Do not use when calling bind::ptr in bind::a --- manifests/a.pp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/manifests/a.pp b/manifests/a.pp index 810f931..6797ab3 100644 --- a/manifests/a.pp +++ b/manifests/a.pp @@ -34,8 +34,7 @@ define bind::a($ensure=present, bind::ptr {$host: ensure => $ensure, zone => $subnet, - owner => $number, - host => $owner, + host => $name, ttl => $ttl, } } -- cgit v1.2.3 From fb0938204019fd14b030605ca8047f1c623bc38c Mon Sep 17 00:00:00 2001 From: Raphaël Pinson Date: Thu, 29 Mar 2012 19:43:18 +0200 Subject: Fix PTR by calculating arpa zones with IPAddr.new(host).reverse --- manifests/a.pp | 8 ++++---- manifests/zone.pp | 6 ++++-- templates/zone-header.erb | 3 +++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/manifests/a.pp b/manifests/a.pp index 6797ab3..41fdee8 100644 --- a/manifests/a.pp +++ b/manifests/a.pp @@ -28,12 +28,12 @@ define bind::a($ensure=present, } if $ptr { - $subnet = inline_template("<%= host.split('.')[0,3].join('.') %>") - $number = inline_template("<%= host.split('.')[3] %>") + $arpa = inline_template("<%= require 'ipaddr'; IPAddr.new(host).reverse %>") + $arpa_zone = inline_template("<%= require 'ipaddr'; IPAddr.new(host).reverse.split('.')[1..-1].join('.') %>") - bind::ptr {$host: + bind::ptr {"${arpa}.": ensure => $ensure, - zone => $subnet, + zone => $arpa_zone, host => $name, ttl => $ttl, } diff --git a/manifests/zone.pp b/manifests/zone.pp index 64da5da..62df7fc 100644 --- a/manifests/zone.pp +++ b/manifests/zone.pp @@ -14,6 +14,7 @@ Arguments: *$zone_ns*: Valid NS for this zone (master only) *$zone_xfers*: IPs. Valid xfers for zone (master only) *$zone_masters*: IPs. Valid master for this zone (slave only) + *$zone_origin*: The origin of the zone */ define bind::zone($ensure=present, @@ -26,7 +27,8 @@ define bind::zone($ensure=present, $zone_expiracy="1w", $zone_ns=false, $zone_xfers=false, - $zone_masters=false) { + $zone_masters=false, + $zone_origin=false) { common::concatfilepart {"bind.zones.${name}": ensure => $ensure, @@ -69,7 +71,7 @@ define bind::zone($ensure=present, content => template("bind/zone-master.erb"), } - common::concatfilepart {"bind.00.${name}": + common::concatfilepart {"00.bind.${name}": ensure => $ensure, file => "/etc/bind/pri/${name}.conf", content => template("bind/zone-header.erb"), diff --git a/templates/zone-header.erb b/templates/zone-header.erb index da93b31..418aef8 100644 --- a/templates/zone-header.erb +++ b/templates/zone-header.erb @@ -1,5 +1,8 @@ ; File managed by puppet $TTL <%=zone_ttl%> +<% if zone_origin -%> +$ORIGIN <%=zone_origin%> +<% end -%> @ IN SOA <%=name%>. <%=zone_contact%>. ( <%=zone_serial%> ; serial <%=zone_refresh%> ; refresh -- cgit v1.2.3 From e9c9acdd15579bcb10ca9509c032819d3f808e53 Mon Sep 17 00:00:00 2001 From: Mathieu Bornoz Date: Thu, 2 Aug 2012 09:30:21 +0200 Subject: switch from common::concatfilepart to concat[1] [1] https://github.com/camptocamp/puppet-concat --- manifests/base.pp | 19 ++++++++++++++----- manifests/init.pp | 3 --- manifests/mx.pp | 6 +++--- manifests/record.pp | 4 ++-- manifests/zone.pp | 38 +++++++++++++++++++++++++------------- 5 files changed, 44 insertions(+), 26 deletions(-) diff --git a/manifests/base.pp b/manifests/base.pp index c442085..752ed58 100644 --- a/manifests/base.pp +++ b/manifests/base.pp @@ -8,6 +8,15 @@ Please refer to Class["bind"]. */ class bind::base { + + include concat::setup + + concat {'/etc/bind/named.conf.local': + owner => root, + group => root, + mode => '0644', + } + package {"bind9": ensure => present, } @@ -18,11 +27,11 @@ class bind::base { require => Package["bind9"], } - file {["/etc/bind/pri", "/etc/bind/zones"]: - ensure => directory, - owner => root, - group => root, - mode => 0755, + file {'/etc/bind/zones': + ensure => directory, + owner => root, + group => root, + mode => 0755, require => Package["bind9"], purge => true, force => true, diff --git a/manifests/init.pp b/manifests/init.pp index d9af708..f81874a 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -3,9 +3,6 @@ = Class: bind Include this class to install bind9 server on your node. -Requires: -- module common (git://github.com/camptocamp/puppet-common.git) - Bind documentation: http://www.bind9.net/manuals diff --git a/manifests/mx.pp b/manifests/mx.pp index 84a2b9f..433c8ea 100644 --- a/manifests/mx.pp +++ b/manifests/mx.pp @@ -24,11 +24,11 @@ define bind::mx($ensure=present, $_owner = $name } - common::concatfilepart{"bind.${name}": - file => "/etc/bind/pri/${zone}", + concat::fragment {"bind.${name}": ensure => $ensure, - notify => Service["bind9"], + target => "/etc/bind/pri/${zone}.conf", content => template("bind/mx-record.erb"), + notify => Service["bind9"], require => [Bind::Zone[$zone], Bind::A[$host]], } } diff --git a/manifests/record.pp b/manifests/record.pp index d551d60..ef53833 100644 --- a/manifests/record.pp +++ b/manifests/record.pp @@ -26,9 +26,9 @@ define bind::record($ensure=present, $_owner = $name } - common::concatfilepart {"${zone}.${record_type}.${name}": + concat::fragment {"${zone}.${record_type}.${name}": ensure => $ensure, - file => "/etc/bind/pri/${zone}.conf", + target => "/etc/bind/pri/${zone}.conf", content => template("bind/default-record.erb"), notify => Service["bind9"], } diff --git a/manifests/zone.pp b/manifests/zone.pp index 62df7fc..6829569 100644 --- a/manifests/zone.pp +++ b/manifests/zone.pp @@ -29,19 +29,31 @@ define bind::zone($ensure=present, $zone_xfers=false, $zone_masters=false, $zone_origin=false) { + + concat {"/etc/bind/pri/${name}.conf": + owner => root, + group => root, + mode => '0644', + } + + concat {"/etc/bind/zones/${name}.conf": + owner => root, + group => root, + mode => '0644', + } - common::concatfilepart {"bind.zones.${name}": + concat::fragment {"bind.zones.${name}": ensure => $ensure, + target => "/etc/bind/zones/${name}.conf", notify => Service["bind9"], - file => "/etc/bind/zones/${name}.conf", require => Package["bind9"], } - common::concatfilepart {"named.local.zone.${name}": + concat::fragment {"named.local.zone.${name}": ensure => $ensure, - notify => Service["bind9"], - file => "/etc/bind/named.conf.local", + target => "/etc/bind/named.conf.local", content => "include \"/etc/bind/zones/${name}.conf\";\n", + notify => Service["bind9"], require => Package["bind9"], } @@ -49,7 +61,7 @@ define bind::zone($ensure=present, if !$zone_masters { fail "No master defined for ${name}!" } - Common::Concatfilepart["bind.zones.${name}"] { + Concat::Fragment["bind.zones.${name}"] { content => template("bind/zone-slave.erb"), } ## END of slave @@ -67,21 +79,21 @@ define bind::zone($ensure=present, fail "No ttl defined for ${name}!" } - Common::Concatfilepart["bind.zones.${name}"] { + Concat::Fragment["bind.zones.${name}"] { content => template("bind/zone-master.erb"), } - common::concatfilepart {"00.bind.${name}": - ensure => $ensure, - file => "/etc/bind/pri/${name}.conf", + concat::fragment {"00.bind.${name}": + ensure => $ensure, + target => "/etc/bind/pri/${name}.conf", content => template("bind/zone-header.erb"), require => Package["bind9"], } file {"/etc/bind/pri/${name}.conf.d": - ensure => directory, - mode => 0700, - purge => true, + ensure => absent, + mode => 0700, + purge => true, recurse => true, backup => false, force => true, -- cgit v1.2.3 From d8f231f802e967bdf5c30bbee61fab05a7621dc6 Mon Sep 17 00:00:00 2001 From: Mathieu Bornoz Date: Thu, 2 Aug 2012 11:24:52 +0200 Subject: lint + cosmetics --- manifests/a.pp | 52 +++++++++++++++-------------- manifests/aaaa.pp | 44 ++++++++++++------------ manifests/base.pp | 28 ++++++++-------- manifests/cname.pp | 45 +++++++++++++------------ manifests/debian.pp | 21 ++++++------ manifests/init.pp | 96 +++++++++++++++++++++++++++-------------------------- manifests/mx.pp | 42 +++++++++++------------ manifests/ns.pp | 45 +++++++++++++------------ manifests/ptr.pp | 45 +++++++++++++------------ manifests/record.pp | 47 +++++++++++++------------- manifests/txt.pp | 45 +++++++++++++------------ manifests/zone.pp | 85 ++++++++++++++++++++++++----------------------- 12 files changed, 301 insertions(+), 294 deletions(-) diff --git a/manifests/a.pp b/manifests/a.pp index 41fdee8..d457413 100644 --- a/manifests/a.pp +++ b/manifests/a.pp @@ -1,34 +1,35 @@ -/* - -= Definition: bind::a -Creates an IPv4 record. - -Arguments: - *$zone*: Bind::Zone name - *$owner*: owner of the Resource Record - *$host*: target of the Resource Record - *$ttl*: Time to Live for the Resource Record. Optional. - *$ptr*: create the corresponding ptr record (default=false) - -*/ -define bind::a($ensure=present, - $zone, - $owner=false, - $host, - $ttl=false, - $ptr=false) { +# = Definition: bind::a +# +# Creates an IPv4 record. +# +# Arguments: +# *$zone*: Bind::Zone name +# *$owner*: owner of the Resource Record +# *$host*: target of the Resource Record +# *$ttl*: Time to Live for the Resource Record. Optional. +# *$ptr*: create the corresponding ptr record (default=false) +# +# +define bind::a( + $zone, + $host, + $ensure = present, + $owner = false, + $ttl = false, + $ptr = false +) { bind::record {$name: - ensure => $ensure, - zone => $zone, - owner => $owner, - host => $host, - ttl => $ttl, + ensure => $ensure, + zone => $zone, + owner => $owner, + host => $host, + ttl => $ttl, record_type => 'A', } if $ptr { - $arpa = inline_template("<%= require 'ipaddr'; IPAddr.new(host).reverse %>") + $arpa = inline_template("<%= require 'ipaddr'; IPAddr.new(host).reverse %>") $arpa_zone = inline_template("<%= require 'ipaddr'; IPAddr.new(host).reverse.split('.')[1..-1].join('.') %>") bind::ptr {"${arpa}.": @@ -38,4 +39,5 @@ define bind::a($ensure=present, ttl => $ttl, } } + } diff --git a/manifests/aaaa.pp b/manifests/aaaa.pp index 80291c2..9466d0f 100644 --- a/manifests/aaaa.pp +++ b/manifests/aaaa.pp @@ -1,27 +1,27 @@ -/* - -= Definition: bind::aaaa -Creates an IPv6 AAAA record. - -Arguments: - *$zone*: Bind::Zone name - *$owner*: owner of the Resource Record - *$host*: target of the Resource Record - *$ttl*: Time to Live for the Resource Record. Optional. - -*/ -define bind::aaaa($ensure=present, - $zone, - $owner=false, - $host, - $ttl=false) { +# = Definition: bind::aaaa +# +# Creates an IPv6 AAAA record. +# +# Arguments: +# *$zone*: Bind::Zone name +# *$owner*: owner of the Resource Record +# *$host*: target of the Resource Record +# *$ttl*: Time to Live for the Resource Record. Optional. +# +define bind::aaaa ( + $zone, + $host, + $ensure = present, + $owner = false, + $ttl = false +) { bind::record {$name: - ensure => $ensure, - zone => $zone, - owner => $owner, - host => $host, - ttl => $ttl, + ensure => $ensure, + zone => $zone, + owner => $owner, + host => $host, + ttl => $ttl, record_type => 'AAAA', } diff --git a/manifests/base.pp b/manifests/base.pp index 752ed58..63eefbc 100644 --- a/manifests/base.pp +++ b/manifests/base.pp @@ -1,12 +1,9 @@ -/* - -= Class: bind::base - -Declares some basic resources. -You should NOT include this class as is, as it won't work at all! -Please refer to Class["bind"]. - -*/ +# = Class: bind::base +# +# Declares some basic resources. +# You should NOT include this class as is, as it won't work at all! +# Please refer to Class['bind']. +# class bind::base { include concat::setup @@ -17,25 +14,26 @@ class bind::base { mode => '0644', } - package {"bind9": + package {'bind9': ensure => present, } - service {"bind9": + service {'bind9': ensure => running, enable => true, - require => Package["bind9"], + require => Package['bind9'], } file {'/etc/bind/zones': ensure => directory, owner => root, group => root, - mode => 0755, - require => Package["bind9"], + mode => '0755', purge => true, force => true, recurse => true, - source => "puppet:///modules/bind/empty", + source => 'puppet:///modules/bind/empty', + require => Package['bind9'], } + } diff --git a/manifests/cname.pp b/manifests/cname.pp index c8baeec..f8eca40 100644 --- a/manifests/cname.pp +++ b/manifests/cname.pp @@ -1,27 +1,28 @@ -/* - -= Definition: bind::cname -Creates a CNAME record. - -Arguments: - *$zone*: Bind::Zone name - *$owner*: owner of the Resource Record - *$host*: target of the Resource Record - *$ttl*: Time to Live for the Resource Record. Optional. - -*/ -define bind::cname($ensure=present, - $zone, - $owner=false, - $host, - $ttl=false) { +# = Definition: bind::cname +# +# Creates a CNAME record. +# +# Arguments: +# *$zone*: Bind::Zone name +# *$owner*: owner of the Resource Record +# *$host*: target of the Resource Record +# *$ttl*: Time to Live for the Resource Record. Optional. +# +define bind::cname ( + $zone, + $host, + $ensure = present, + $owner = false, + $ttl = false +) { bind::record {$name: - ensure => $ensure, - zone => $zone, - owner => $owner, - host => $host, - ttl => $ttl, + ensure => $ensure, + zone => $zone, + owner => $owner, + host => $host, + ttl => $ttl, record_type => 'CNAME', } + } diff --git a/manifests/debian.pp b/manifests/debian.pp index 7b752ae..41e356e 100644 --- a/manifests/debian.pp +++ b/manifests/debian.pp @@ -1,14 +1,13 @@ -/* - -= Class: bind::debian -Special debian class - inherits from bind::base - -You should not include this class - please refer to Class["bind"] - -*/ +# = Class: bind::debian +# Special debian class - inherits from bind::base +# +# You should not include this class - please refer to Class["bind"] +# class bind::debian inherits bind::base { - Service["bind9"] { - pattern => "/usr/sbin/named", - restart => "/etc/init.d/bind9 reload", + + Service['bind9'] { + pattern => '/usr/sbin/named', + restart => '/etc/init.d/bind9 reload', } + } diff --git a/manifests/init.pp b/manifests/init.pp index f81874a..ff88737 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,51 +1,53 @@ -/* - -= Class: bind -Include this class to install bind9 server on your node. - -Bind documentation: -http://www.bind9.net/manuals - -Limitations: -This modules is valid for Bind 9.7.1 (squeeze version). -For 9.7.2, it will be really limited (no view nor ACL support). - - -Example: - -node "ns1.domain.ltd" { - include bind - bind::zone {"domain.ltd": - ensure => present, - zone_contact => "contact.domain.ltd", - zone_ns => $fqdn, - zone_serial => "2010110804", - zone_ttl => "604800", - } - - bind::a {"ns $fqdn": - zone => "domain.ltd", - owner => "${fqdn}.", - host => $ipaddress, - } +# = Class: bind +# Include this class to install bind9 server on your node. +# +# Bind documentation: +# http://www.bind9.net/manuals +# +# Limitations: +# This modules is valid for Bind 9.7.1 (squeeze version). +# For 9.7.2, it will be really limited (no view nor ACL support). +# +# +# Example: +# +# node 'ns1.domain.ltd' { +# +# include bind +# +# bind::zone {'domain.ltd': +# ensure => present, +# zone_contact => "contact.domain.ltd", +# zone_ns => $fqdn, +# zone_serial => '2010110804', +# zone_ttl => '604800', +# } +# +# bind::a {"ns $fqdn": +# zone => 'domain.ltd', +# owner => "${fqdn}.", +# host => $ipaddress, +# } +# +# bind::a {'mail.domain.ltd': +# zone => 'domain.ltd', +# owner => 'mail', +# host => '6.6.6.6', +# } +# +# bind::mx {'mx1': +# zone => 'domain.ltd', +# owner => '@', +# priority => 1, +# host => 'mail.domain.ltd', +# } +# } +# +class bind { - bind::a {"mail.domain.ltd": - zone => "domain.ltd", - owner => "mail", - host => "6.6.6.6", + case $::operatingsystem { + 'Debian','Ubuntu': { include bind::debian } + default : { fail "Unknown ${::operatingsystem}" } } - bind::mx {"mx1": - zone => "domain.ltd", - owner => "@", - priority => 1, - host => "mail.domain.ltd", - } -} -*/ -class bind { - case $operatingsystem { - "Debian","Ubuntu": { include bind::debian } - default: { fail "Unknown $operatingsystem" } - } } diff --git a/manifests/mx.pp b/manifests/mx.pp index 433c8ea..4404a83 100644 --- a/manifests/mx.pp +++ b/manifests/mx.pp @@ -1,22 +1,21 @@ -/* - -= Definition: bind::mx -Creates an MX record. - -Arguments: - *$zone*: Bind::Zone name - *$owner*: owner of the Resource Record - *$priority*: MX record priority - *$host*: target of the Resource Record - *$ttl*: Time to Live for the Resource Record. Optional. - -*/ -define bind::mx($ensure=present, - $zone, - $owner=false, - $priority, - $host, - $ttl=false) { +# = Definition: bind::mx +# Creates an MX record. +# +# Arguments: +# *$zone*: Bind::Zone name +# *$owner*: owner of the Resource Record +# *$priority*: MX record priority +# *$host*: target of the Resource Record +# *$ttl*: Time to Live for the Resource Record. Optional. +# +define bind::mx ( + $zone, + $host, + $priority, + $ensure = present, + $owner = false, + $ttl = false +) { if $owner { $_owner = $owner @@ -27,9 +26,10 @@ define bind::mx($ensure=present, concat::fragment {"bind.${name}": ensure => $ensure, target => "/etc/bind/pri/${zone}.conf", - content => template("bind/mx-record.erb"), - notify => Service["bind9"], + content => template('bind/mx-record.erb'), + notify => Service['bind9'], require => [Bind::Zone[$zone], Bind::A[$host]], } + } diff --git a/manifests/ns.pp b/manifests/ns.pp index 3d07aea..e0fbeef 100644 --- a/manifests/ns.pp +++ b/manifests/ns.pp @@ -1,27 +1,28 @@ -/* - -= Definition: bind::ns -Creates an NS record. - -Arguments: - *$zone*: Bind::Zone name - *$owner*: owner of the Resource Record - *$host*: target of the Resource Record - *$ttl*: Time to Live for the Resource Record. Optional. - -*/ -define bind::ns($ensure=present, - $zone, - $owner=false, - $host, - $ttl=false) { +# = Definition: bind::ns +# +# Creates an NS record. +# +# Arguments: +# *$zone*: Bind::Zone name +# *$owner*: owner of the Resource Record +# *$host*: target of the Resource Record +# *$ttl*: Time to Live for the Resource Record. Optional. +# +define bind::ns ( + $zone, + $host, + $ensure = present, + $owner = false, + $ttl = false +) { bind::record {$name: - ensure => $ensure, - zone => $zone, - owner => $owner, - host => $host, - ttl => $ttl, + ensure => $ensure, + zone => $zone, + owner => $owner, + host => $host, + ttl => $ttl, record_type => 'NS', } + } diff --git a/manifests/ptr.pp b/manifests/ptr.pp index 1904c5d..d4bb052 100644 --- a/manifests/ptr.pp +++ b/manifests/ptr.pp @@ -1,27 +1,28 @@ -/* - -= Definition: bind::ptr -Creates a PTR record. - -Arguments: - *$zone*: Bind::Zone name - *$owner*: number of the Resource Record - *$host*: target of the Resource Record - *$ttl*: Time to Live for the Resource Record. Optional. - -*/ -define bind::ptr($ensure=present, - $zone, - $owner=false, - $host, - $ttl=false) { +# = Definition: bind::ptr +# +# Creates a PTR record. +# +# Arguments: +# *$zone*: Bind::Zone name +# *$owner*: number of the Resource Record +# *$host*: target of the Resource Record +# *$ttl*: Time to Live for the Resource Record. Optional. +# +define bind::ptr( + $zone, + $host, + $ensure = present, + $owner = false, + $ttl = false +) { bind::record {$name: - ensure => $ensure, - zone => $zone, - owner => $owner, - host => $host, - ttl => $ttl, + ensure => $ensure, + zone => $zone, + owner => $owner, + host => $host, + ttl => $ttl, record_type => 'PTR', } + } diff --git a/manifests/record.pp b/manifests/record.pp index ef53833..dc43aaa 100644 --- a/manifests/record.pp +++ b/manifests/record.pp @@ -1,24 +1,24 @@ -/* - -= Definition: bind::record -Helper to create any record you want (but NOT MX, please refer to Bind::Mx) - -Arguments: - *$zone*: Bind::Zone name - *$owner*: owner of the Resource Record - *$host*: target of the Resource Record - *$record_type°: resource record type - *$record_class*: resource record class. Default "IN". - *$ttl*: Time to Live for the Resource Record. Optional. - -*/ -define bind::record($ensure=present, - $zone, - $owner=false, - $host, - $record_type, - $record_class='IN', - $ttl=false) { +# = Definition: bind::record +# +# Helper to create any record you want (but NOT MX, please refer to Bind::Mx) +# +# Arguments: +# *$zone*: Bind::Zone name +# *$owner*: owner of the Resource Record +# *$host*: target of the Resource Record +# *$record_type°: resource record type +# *$record_class*: resource record class. Default "IN". +# *$ttl*: Time to Live for the Resource Record. Optional. +# +define bind::record ( + $zone, + $host, + $record_type, + $ensure = present, + $owner = false, + $record_class = 'IN', + $ttl = false +) { if $owner { $_owner = $owner @@ -29,7 +29,8 @@ define bind::record($ensure=present, concat::fragment {"${zone}.${record_type}.${name}": ensure => $ensure, target => "/etc/bind/pri/${zone}.conf", - content => template("bind/default-record.erb"), - notify => Service["bind9"], + content => template('bind/default-record.erb'), + notify => Service['bind9'], } + } diff --git a/manifests/txt.pp b/manifests/txt.pp index 31dd189..92b3ba4 100644 --- a/manifests/txt.pp +++ b/manifests/txt.pp @@ -1,27 +1,28 @@ -/* - -= Definition: bind::txt -Creates an IPv4 record. - -Arguments: - *$zone*: Bind::Zone name - *$owner*: owner of the Resource Record - *$text*: target of the Resource Record - *$ttl*: Time to Live for the Resource Record. Optional. - -*/ -define bind::txt($ensure=present, - $zone, - $owner=false, - $text, - $ttl=false) { +# = Definition: bind::txt +# +# Creates an IPv4 record. +# +# Arguments: +# *$zone*: Bind::Zone name +# *$owner*: owner of the Resource Record +# *$text*: target of the Resource Record +# *$ttl*: Time to Live for the Resource Record. Optional. +# +define bind::txt ( + $zone, + $text, + $ensure = present, + $owner = false, + $ttl = false +) { bind::record {$name: - ensure => $ensure, - zone => $zone, - owner => $owner, - host => $text, - ttl => $ttl, + ensure => $ensure, + zone => $zone, + owner => $owner, + host => $text, + ttl => $ttl, record_type => 'TXT', } + } diff --git a/manifests/zone.pp b/manifests/zone.pp index 6829569..eb07746 100644 --- a/manifests/zone.pp +++ b/manifests/zone.pp @@ -1,41 +1,41 @@ -/* +# = Definition: bind::zone +# +# Creates a valid Bind9 zone. +# +# Arguments: +# *$is_slave*: Boolean. Is your zone a slave or a master? Default false +# *$zone_ttl*: Time period. Time to live for your zonefile (master only) +# *$zone_contact*: Valid contact record (master only) +# *$zone_serial*: Integer. Zone serial (master only) +# *$zone_refresh*: Time period. Time between each slave refresh (master only) +# *$zone_retry*: Time period. Time between each slave retry (master only) +# *$zone_expiracy*: Time period. Slave expiracy time (master only) +# *$zone_ns*: Valid NS for this zone (master only) +# *$zone_xfers*: IPs. Valid xfers for zone (master only) +# *$zone_masters*: IPs. Valid master for this zone (slave only) +# *$zone_origin*: The origin of the zone +# +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, + $zone_origin = false +) { -= Definition: bind::zone -Creates a valid Bind9 zone. - -Arguments: - *$is_slave*: Boolean. Is your zone a slave or a master? Default false - *$zone_ttl*: Time period. Time to live for your zonefile (master only) - *$zone_contact*: Valid contact record (master only) - *$zone_serial*: Integer. Zone serial (master only) - *$zone_refresh*: Time period. Time between each slave refresh (master only) - *$zone_retry*: Time period. Time between each slave retry (master only) - *$zone_expiracy*: Time period. Slave expiracy time (master only) - *$zone_ns*: Valid NS for this zone (master only) - *$zone_xfers*: IPs. Valid xfers for zone (master only) - *$zone_masters*: IPs. Valid master for this zone (slave only) - *$zone_origin*: The origin of the zone - -*/ -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, - $zone_origin=false) { - concat {"/etc/bind/pri/${name}.conf": owner => root, group => root, mode => '0644', } - + concat {"/etc/bind/zones/${name}.conf": owner => root, group => root, @@ -45,16 +45,16 @@ define bind::zone($ensure=present, concat::fragment {"bind.zones.${name}": ensure => $ensure, target => "/etc/bind/zones/${name}.conf", - notify => Service["bind9"], - require => Package["bind9"], + notify => Service['bind9'], + require => Package['bind9'], } concat::fragment {"named.local.zone.${name}": ensure => $ensure, - target => "/etc/bind/named.conf.local", + target => '/etc/bind/named.conf.local', content => "include \"/etc/bind/zones/${name}.conf\";\n", - notify => Service["bind9"], - require => Package["bind9"], + notify => Service['bind9'], + require => Package['bind9'], } if $is_slave { @@ -62,7 +62,7 @@ define bind::zone($ensure=present, fail "No master defined for ${name}!" } Concat::Fragment["bind.zones.${name}"] { - content => template("bind/zone-slave.erb"), + content => template('bind/zone-slave.erb'), } ## END of slave } else { @@ -80,23 +80,24 @@ define bind::zone($ensure=present, } Concat::Fragment["bind.zones.${name}"] { - content => template("bind/zone-master.erb"), + content => template('bind/zone-master.erb'), } concat::fragment {"00.bind.${name}": ensure => $ensure, target => "/etc/bind/pri/${name}.conf", - content => template("bind/zone-header.erb"), - require => Package["bind9"], + content => template('bind/zone-header.erb'), + require => Package['bind9'], } file {"/etc/bind/pri/${name}.conf.d": ensure => absent, - mode => 0700, + mode => '0700', purge => true, recurse => true, backup => false, force => true, } } + } -- cgit v1.2.3 From d90ebaf03c69693bf5c2cccd74ea267fca325c6d Mon Sep 17 00:00:00 2001 From: Cédric Jeanneret Date: Fri, 9 Nov 2012 15:24:08 +0100 Subject: corrected how bind modules removes a zone --- manifests/zone.pp | 124 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 68 insertions(+), 56 deletions(-) diff --git a/manifests/zone.pp b/manifests/zone.pp index eb07746..d7fbc40 100644 --- a/manifests/zone.pp +++ b/manifests/zone.pp @@ -30,25 +30,6 @@ define bind::zone ( $zone_origin = false ) { - concat {"/etc/bind/pri/${name}.conf": - owner => root, - group => root, - mode => '0644', - } - - concat {"/etc/bind/zones/${name}.conf": - owner => root, - group => root, - mode => '0644', - } - - concat::fragment {"bind.zones.${name}": - ensure => $ensure, - target => "/etc/bind/zones/${name}.conf", - notify => Service['bind9'], - require => Package['bind9'], - } - concat::fragment {"named.local.zone.${name}": ensure => $ensure, target => '/etc/bind/named.conf.local', @@ -57,47 +38,78 @@ define bind::zone ( require => Package['bind9'], } - if $is_slave { - if !$zone_masters { - fail "No master defined for ${name}!" - } - Concat::Fragment["bind.zones.${name}"] { - content => template('bind/zone-slave.erb'), - } + case $ensure { + present: { + concat {"/etc/bind/pri/${name}.conf": + owner => root, + group => root, + mode => '0644', + } + + concat {"/etc/bind/zones/${name}.conf": + owner => root, + group => root, + mode => '0644', + } + concat::fragment {"bind.zones.${name}": + ensure => $ensure, + target => "/etc/bind/zones/${name}.conf", + notify => Service['bind9'], + require => Package['bind9'], + } + + + if $is_slave { + if !$zone_masters { + fail "No master defined for ${name}!" + } + Concat::Fragment["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}!" - } + } 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}!" + } - Concat::Fragment["bind.zones.${name}"] { - content => template('bind/zone-master.erb'), - } + Concat::Fragment["bind.zones.${name}"] { + content => template('bind/zone-master.erb'), + } - concat::fragment {"00.bind.${name}": - ensure => $ensure, - target => "/etc/bind/pri/${name}.conf", - content => template('bind/zone-header.erb'), - require => Package['bind9'], - } + concat::fragment {"00.bind.${name}": + ensure => $ensure, + target => "/etc/bind/pri/${name}.conf", + content => template('bind/zone-header.erb'), + require => Package['bind9'], + } - file {"/etc/bind/pri/${name}.conf.d": - ensure => absent, - mode => '0700', - purge => true, - recurse => true, - backup => false, - force => true, + file {"/etc/bind/pri/${name}.conf.d": + ensure => absent, + mode => '0700', + purge => true, + recurse => true, + backup => false, + force => true, + } + } } + absent: { + file {"/etc/bind/pri/${name}.conf": + ensure => absent, + } + file {"/etc/bind/zones/${name}.conf": + ensure => absent, + } + } + default: {} } - } -- cgit v1.2.3 From 0e517403f9789ad7655e3e87c43a0c70c6e1d494 Mon Sep 17 00:00:00 2001 From: Cédric Jeanneret Date: Wed, 14 Nov 2012 14:25:03 +0100 Subject: corrected bind::zone in order to make slave zones work correctly --- manifests/zone.pp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/manifests/zone.pp b/manifests/zone.pp index d7fbc40..1b61788 100644 --- a/manifests/zone.pp +++ b/manifests/zone.pp @@ -40,12 +40,6 @@ define bind::zone ( case $ensure { present: { - concat {"/etc/bind/pri/${name}.conf": - owner => root, - group => root, - mode => '0644', - } - concat {"/etc/bind/zones/${name}.conf": owner => root, group => root, @@ -81,6 +75,13 @@ define bind::zone ( fail "No ttl defined for ${name}!" } + concat {"/etc/bind/pri/${name}.conf": + owner => root, + group => root, + mode => '0644', + } + + Concat::Fragment["bind.zones.${name}"] { content => template('bind/zone-master.erb'), } -- cgit v1.2.3 From 93ad475ebdee5685f52e1ca943581f48298851a7 Mon Sep 17 00:00:00 2001 From: Cédric Jeanneret Date: Wed, 14 Nov 2012 14:25:19 +0100 Subject: corrected template for slave zones - missing ; --- templates/zone-slave.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/zone-slave.erb b/templates/zone-slave.erb index b5b3754..5f6acca 100644 --- a/templates/zone-slave.erb +++ b/templates/zone-slave.erb @@ -8,4 +8,4 @@ zone <%=name%> IN { <% end -%> allow-query { any; }; notify yes; -} +}; -- cgit v1.2.3 From 46c18476c831322abc947bfa4dfee29d3a68b58f Mon Sep 17 00:00:00 2001 From: Cédric Jeanneret Date: Thu, 15 Nov 2012 12:39:07 +0100 Subject: slave cannot notify on update --- templates/zone-slave.erb | 1 - 1 file changed, 1 deletion(-) diff --git a/templates/zone-slave.erb b/templates/zone-slave.erb index 5f6acca..0ae7e5d 100644 --- a/templates/zone-slave.erb +++ b/templates/zone-slave.erb @@ -7,5 +7,4 @@ zone <%=name%> IN { masters { <%= zone_masters %>; }; <% end -%> allow-query { any; }; - notify yes; }; -- cgit v1.2.3 From 4b13fbe430e59ba098cd984dca4731ed02208856 Mon Sep 17 00:00:00 2001 From: Cédric Jeanneret Date: Mon, 19 Nov 2012 11:18:04 +0100 Subject: Merge commit '22c2c4e2928cf62fd8ab2c1b19472246b07c4265' into staging --- templates/zone-slave.erb | 1 - 1 file changed, 1 deletion(-) diff --git a/templates/zone-slave.erb b/templates/zone-slave.erb index 5f6acca..0ae7e5d 100644 --- a/templates/zone-slave.erb +++ b/templates/zone-slave.erb @@ -7,5 +7,4 @@ zone <%=name%> IN { masters { <%= zone_masters %>; }; <% end -%> allow-query { any; }; - notify yes; }; -- cgit v1.2.3 From 6f23806d1fc695c6945c049125d0fbd48616efcc Mon Sep 17 00:00:00 2001 From: Cédric Jeanneret Date: Thu, 29 Nov 2012 12:11:03 +0100 Subject: New bind::generate definition and related ERB template New Bind directive, allowing to reduce a bit the resources amount using the internal Bind $GENERATE directive. Please have a look at embedded documentation for more information on this new definition usage. --- manifests/generate.pp | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++ templates/generate.erb | 1 + 2 files changed, 88 insertions(+) create mode 100644 manifests/generate.pp create mode 100644 templates/generate.erb diff --git a/manifests/generate.pp b/manifests/generate.pp new file mode 100644 index 0000000..49a56dc --- /dev/null +++ b/manifests/generate.pp @@ -0,0 +1,87 @@ +# = definition: bind::generate +# +# Creates a $GENERATE directive for a specific zone +# +# == Arguments +# $zone: mandatory - zone name. Must reflect a bind::zone resource +# $range: mandatory - range allocated to internal generate directive. +# Must be in the form 'first-last', like '2-254' +# $record_type: mandatory - must be one of PTR, CNAME, DNAME, A, AAAA and NS +# $lhs: mandatory - generated name (see examples) +# $rhs: mandatory - record target (see examples) +# $record_class: optional - incompatible with pre-9.3 bind versions +# $ttl: optional - time tolive for generated records +# +# == Examples +# +# bind::zone {'test.tld': +# zone_contact => 'contact.test.tld', +# zone_ns => 'ns0.test.tld', +# zone_serial => '2012112901', +# zone_ttl => '604800', +# zone_origin => 'test.tld', +# } +# ## Generate A records +# bind::generate {'a-records': +# zone => 'test.tld', +# range => '2-100', +# record_type => 'A', +# lhs => 'dhcp-$', # creates dhcp-2.test.tld, dhcp-3.test.tld … +# rhs => '10.10.0.$', # creates IP 10.10.0.2, 10.10.0.3 … +# } +# ## Means: dig dhcp-10.test.tld will resolv to 10.10.0.10 +# +# ## Generate CNAME records +# bind::generate {'a-records': +# zone => 'test.tld', +# range => '2-100', +# record_type => 'CNAME', +# lhs => 'dhcp-$', # creates dhcp-2.test.tld, dhcp-3.test.tld … +# rhs => 'dhcp$', # creates IP dhcp2.test.tld, dhcp3.test.tld … +# } +# ## Means: dig dhcp10.test.tld => dhcp-10.test.tld => 10.10.0.10 +# +# bind::zone {'0.10.10.IN-ADDR.ARPA': +# zone_contact => 'contact.test.tld', +# zone_ns => 'ns0.test.tld', +# zone_serial => '2012112901', +# zone_ttl => '604800', +# zone_origin => '0.10.10.IN-ADDR.ARPA', +# } +# ## Generates PTR +# bind::generate {'ptr-records': +# zone => '0.10.10.IN-ADDR.ARPA', +# range => '2-100', +# record_type => 'PTR', +# lhs => '$.0.10.10.IN-ADDR.ARPA.', # 2.0.10.10.IN-ADDR.ARPA … +# rhs => 'dhcp-$.test.tld.', # creates dhcp-2.test.tld … +# } +# ## Means: dig 10.10.0.10 will resolv to dhcp-10.test.tld +# +# +# For more information regarding this directive +# and the definition arguments, please have a +# look at +# http://www.bind9.net/manual/bind/9.3.2/Bv9ARM.ch06.html#id2566761 +# +# NOTE: in order to prevent some funky-funny thing, the orignal +# "class" and "type" variables +# are renamed as $record_class and $record_type in this definition. +# +define bind::generate( + $zone, + $range, + $record_type, + $lhs, + $rhs, + $ensure=present, + $record_class='', + $ttl='') { + + concat::fragment {"${zone}.${record_type}.${range}.generate": + ensure => $ensure, + target => "/etc/bind/pri/${zone}.conf", + content => template('bind/generate.erb'), + notify => Service['bind9'], + } +} diff --git a/templates/generate.erb b/templates/generate.erb new file mode 100644 index 0000000..0c15823 --- /dev/null +++ b/templates/generate.erb @@ -0,0 +1 @@ +$GENERATE <%=range%> <%=lhs%> <%=ttl%> <%=record_class%> <%=record_type%> <%=rhs%> ; <%=name%> -- cgit v1.2.3 From 11230d379bd51164ef1c05b3825d229baf196eed Mon Sep 17 00:00:00 2001 From: Cédric Jeanneret Date: Thu, 27 Dec 2012 10:25:44 +0100 Subject: removed require on A record This require break when we have an external MX, like googleApps or else. As it's an external MX, it's useless (and really NOT recommanded) to manage its A record ;). --- manifests/mx.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/mx.pp b/manifests/mx.pp index 4404a83..f8ee34d 100644 --- a/manifests/mx.pp +++ b/manifests/mx.pp @@ -28,7 +28,7 @@ define bind::mx ( target => "/etc/bind/pri/${zone}.conf", content => template('bind/mx-record.erb'), notify => Service['bind9'], - require => [Bind::Zone[$zone], Bind::A[$host]], + require => Bind::Zone[$zone], } } -- cgit v1.2.3 From fe6e8b70e297c3d9cc95a216152273e2409c59d3 Mon Sep 17 00:00:00 2001 From: Christian Kaenzig Date: Thu, 27 Dec 2012 11:14:27 +0100 Subject: remove unnecessary empty source --- files/empty/.placeholder | 0 manifests/base.pp | 1 - 2 files changed, 1 deletion(-) delete mode 100644 files/empty/.placeholder diff --git a/files/empty/.placeholder b/files/empty/.placeholder deleted file mode 100644 index e69de29..0000000 diff --git a/manifests/base.pp b/manifests/base.pp index 63eefbc..24dae08 100644 --- a/manifests/base.pp +++ b/manifests/base.pp @@ -32,7 +32,6 @@ class bind::base { purge => true, force => true, recurse => true, - source => 'puppet:///modules/bind/empty', require => Package['bind9'], } -- cgit v1.2.3 From 1c601ade41fbafa259cfbc71666387dc97333755 Mon Sep 17 00:00:00 2001 From: Christian Kaenzig Date: Thu, 27 Dec 2012 11:15:09 +0100 Subject: fix concat error when no zone is defined --- manifests/base.pp | 1 + 1 file changed, 1 insertion(+) diff --git a/manifests/base.pp b/manifests/base.pp index 24dae08..369100a 100644 --- a/manifests/base.pp +++ b/manifests/base.pp @@ -12,6 +12,7 @@ class bind::base { owner => root, group => root, mode => '0644', + force => true, } package {'bind9': -- cgit v1.2.3 From fba4bdbbab794d46f4fe00f0aa4e60458d33f3f7 Mon Sep 17 00:00:00 2001 From: Christian Kaenzig Date: Thu, 10 Jan 2013 12:01:48 +0100 Subject: bind::mx: remove problematic require Dependencies within this module must largely be assured by the use of concat. This require seems useless and can actually create dependency loops. --- manifests/mx.pp | 1 - 1 file changed, 1 deletion(-) diff --git a/manifests/mx.pp b/manifests/mx.pp index f8ee34d..0df5b6f 100644 --- a/manifests/mx.pp +++ b/manifests/mx.pp @@ -28,7 +28,6 @@ define bind::mx ( target => "/etc/bind/pri/${zone}.conf", content => template('bind/mx-record.erb'), notify => Service['bind9'], - require => Bind::Zone[$zone], } } -- cgit v1.2.3