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