summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeanneret Cedric <contact@internux.ch>2012-12-03 04:31:01 -0800
committerJeanneret Cedric <contact@internux.ch>2012-12-03 04:31:01 -0800
commit6e57c53d0aa2473461d56b8e4479ca77f22c52dc (patch)
treeeef7c2515f2c6663335e8b38fada9835947a923b
parent22c2c4e2928cf62fd8ab2c1b19472246b07c4265 (diff)
parent6f23806d1fc695c6945c049125d0fbd48616efcc (diff)
downloadpuppet-bind-6e57c53d0aa2473461d56b8e4479ca77f22c52dc.tar.gz
puppet-bind-6e57c53d0aa2473461d56b8e4479ca77f22c52dc.tar.bz2
Merge pull request #10 from cjeanneret/bind-generate
Bind generate
-rw-r--r--manifests/generate.pp87
-rw-r--r--templates/generate.erb1
2 files changed, 88 insertions, 0 deletions
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%>