summaryrefslogtreecommitdiff
path: root/manifests
diff options
context:
space:
mode:
Diffstat (limited to 'manifests')
-rw-r--r--manifests/a.pp43
-rw-r--r--manifests/aaaa.pp28
-rw-r--r--manifests/base.pp39
-rw-r--r--manifests/classes/bind-base.pp32
-rw-r--r--manifests/classes/bind-debian.pp14
-rw-r--r--manifests/classes/bind.pp54
-rw-r--r--manifests/cname.pp28
-rw-r--r--manifests/debian.pp13
-rw-r--r--manifests/definitions/bind-a.pp27
-rw-r--r--manifests/definitions/bind-aaaa.pp28
-rw-r--r--manifests/definitions/bind-cname.pp27
-rw-r--r--manifests/definitions/bind-mx.pp34
-rw-r--r--manifests/definitions/bind-ns.pp27
-rw-r--r--manifests/definitions/bind-record.pp35
-rw-r--r--manifests/definitions/bind-zone.pp88
-rw-r--r--manifests/generate.pp87
-rw-r--r--manifests/init.pp55
-rw-r--r--manifests/mx.pp34
-rw-r--r--manifests/ns.pp28
-rw-r--r--manifests/ptr.pp28
-rw-r--r--manifests/record.pp36
-rw-r--r--manifests/txt.pp28
-rw-r--r--manifests/zone.pp116
23 files changed, 561 insertions, 368 deletions
diff --git a/manifests/a.pp b/manifests/a.pp
new file mode 100644
index 0000000..d457413
--- /dev/null
+++ b/manifests/a.pp
@@ -0,0 +1,43 @@
+# = 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,
+ record_type => 'A',
+ }
+
+ if $ptr {
+ $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}.":
+ ensure => $ensure,
+ zone => $arpa_zone,
+ host => $name,
+ ttl => $ttl,
+ }
+ }
+
+}
diff --git a/manifests/aaaa.pp b/manifests/aaaa.pp
new file mode 100644
index 0000000..9466d0f
--- /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 (
+ $zone,
+ $host,
+ $ensure = present,
+ $owner = false,
+ $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..369100a
--- /dev/null
+++ b/manifests/base.pp
@@ -0,0 +1,39 @@
+# = 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
+
+ concat {'/etc/bind/named.conf.local':
+ owner => root,
+ group => root,
+ mode => '0644',
+ force => true,
+ }
+
+ package {'bind9':
+ ensure => present,
+ }
+
+ service {'bind9':
+ ensure => running,
+ enable => true,
+ require => Package['bind9'],
+ }
+
+ file {'/etc/bind/zones':
+ ensure => directory,
+ owner => root,
+ group => root,
+ mode => '0755',
+ purge => true,
+ force => true,
+ recurse => true,
+ require => Package['bind9'],
+ }
+
+}
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..f8eca40
--- /dev/null
+++ b/manifests/cname.pp
@@ -0,0 +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 (
+ $zone,
+ $host,
+ $ensure = present,
+ $owner = false,
+ $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..41e356e
--- /dev/null
+++ b/manifests/debian.pp
@@ -0,0 +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 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 10f34b8..0000000
--- a/manifests/definitions/bind-mx.pp
+++ /dev/null
@@ -1,34 +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}.conf",
- ensure => $ensure,
- notify => Service["bind9"],
- content => template("bind/mx-record.erb"),
- }
-}
-
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/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/manifests/init.pp b/manifests/init.pp
index 6cc1969..ff88737 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -1,2 +1,53 @@
-import "classes/*.pp"
-import "definitions/*.pp"
+# = 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 {
+
+ 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..0df5b6f
--- /dev/null
+++ b/manifests/mx.pp
@@ -0,0 +1,34 @@
+# = 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
+ } else {
+ $_owner = $name
+ }
+
+ concat::fragment {"bind.${name}":
+ ensure => $ensure,
+ target => "/etc/bind/pri/${zone}.conf",
+ content => template('bind/mx-record.erb'),
+ notify => Service['bind9'],
+ }
+
+}
+
diff --git a/manifests/ns.pp b/manifests/ns.pp
new file mode 100644
index 0000000..e0fbeef
--- /dev/null
+++ b/manifests/ns.pp
@@ -0,0 +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 (
+ $zone,
+ $host,
+ $ensure = present,
+ $owner = false,
+ $ttl = false
+) {
+
+ bind::record {$name:
+ ensure => $ensure,
+ zone => $zone,
+ owner => $owner,
+ host => $host,
+ ttl => $ttl,
+ record_type => 'NS',
+ }
+
+}
diff --git a/manifests/ptr.pp b/manifests/ptr.pp
new file mode 100644
index 0000000..d4bb052
--- /dev/null
+++ b/manifests/ptr.pp
@@ -0,0 +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(
+ $zone,
+ $host,
+ $ensure = present,
+ $owner = false,
+ $ttl = false
+) {
+
+ bind::record {$name:
+ ensure => $ensure,
+ zone => $zone,
+ owner => $owner,
+ host => $host,
+ ttl => $ttl,
+ record_type => 'PTR',
+ }
+
+}
diff --git a/manifests/record.pp b/manifests/record.pp
new file mode 100644
index 0000000..dc43aaa
--- /dev/null
+++ b/manifests/record.pp
@@ -0,0 +1,36 @@
+# = 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
+ } else {
+ $_owner = $name
+ }
+
+ concat::fragment {"${zone}.${record_type}.${name}":
+ ensure => $ensure,
+ target => "/etc/bind/pri/${zone}.conf",
+ content => template('bind/default-record.erb'),
+ notify => Service['bind9'],
+ }
+
+}
diff --git a/manifests/txt.pp b/manifests/txt.pp
new file mode 100644
index 0000000..92b3ba4
--- /dev/null
+++ b/manifests/txt.pp
@@ -0,0 +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 (
+ $zone,
+ $text,
+ $ensure = present,
+ $owner = false,
+ $ttl = false
+) {
+
+ bind::record {$name:
+ ensure => $ensure,
+ zone => $zone,
+ owner => $owner,
+ host => $text,
+ ttl => $ttl,
+ record_type => 'TXT',
+ }
+
+}
diff --git a/manifests/zone.pp b/manifests/zone.pp
new file mode 100644
index 0000000..1b61788
--- /dev/null
+++ b/manifests/zone.pp
@@ -0,0 +1,116 @@
+# = 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::fragment {"named.local.zone.${name}":
+ ensure => $ensure,
+ target => '/etc/bind/named.conf.local',
+ content => "include \"/etc/bind/zones/${name}.conf\";\n",
+ notify => Service['bind9'],
+ require => Package['bind9'],
+ }
+
+ case $ensure {
+ present: {
+ 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}!"
+ }
+
+ concat {"/etc/bind/pri/${name}.conf":
+ owner => root,
+ group => root,
+ mode => '0644',
+ }
+
+
+ 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'],
+ }
+
+ 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: {}
+ }
+}