From 21ffc24acf9b071b0c6335644562f11c6884db14 Mon Sep 17 00:00:00 2001 From: Jussi Date: Thu, 19 Jan 2012 12:34:52 +0200 Subject: [PATCH] Added support for master and slave zones. --- dns/templates/db.erb | 22 +++++++++++++++------- dns/templates/named.conf.local.erb | 6 +----- dns/templates/zone.master.erb | 11 +++++++++++ dns/templates/zone.slave.erb | 9 +++++++++ 4 files changed, 36 insertions(+), 12 deletions(-) create mode 100644 dns/templates/zone.master.erb create mode 100644 dns/templates/zone.slave.erb diff --git a/dns/templates/db.erb b/dns/templates/db.erb index b78c6f1..8b97915 100644 --- a/dns/templates/db.erb +++ b/dns/templates/db.erb @@ -3,16 +3,24 @@ ; ; -$TTL 86400 -@ IN SOA ns1.<%= zone %>. root.<%= zone %>. ( +$TTL 3600 +<% master.each do |m| -%> +@ IN SOA <%= m['name'] %>. root.<%= zone %>. ( <%= Time.now.to_i %> ; Serial - 604800 ; Refresh - 86400 ; Retry - 2419200 ; Expire + 3600 ; Refresh + 7200 ; Retry + 604800 ; Expire 86400 ) ; Negative Cache TTL +<% end -%> ; -@ IN NS ns1.<%= zone %>. -ns1 IN A <%= ipaddr %> +<% master.each do |m| -%> +@ IN NS <%= m['name'] %>. +<% end -%> +<% if has_variable?(slaves) -%> + <% slaves.each do |slave| -%> +@ IN NS <%= slave['name'] %>. + <% end -%> +<% end -%> $INCLUDE /etc/bind/db.<%= zone %>-dynamic $INCLUDE /etc/bind/db.<%= zone %>-static diff --git a/dns/templates/named.conf.local.erb b/dns/templates/named.conf.local.erb index 99c5853..35c5b34 100644 --- a/dns/templates/named.conf.local.erb +++ b/dns/templates/named.conf.local.erb @@ -19,13 +19,9 @@ acl "trusted" { }; <% dns_zones.each do |zone| -%> -zone "<%= zone %>" { - type master; - file "/etc/bind/db.<%= zone %>"; -}; +include "/etc/bind/zone.<%= zone %>"; <% end -%> - // Consider adding the 1918 zones here, if they are not used in your // organization //include "/etc/bind/zones.rfc1918"; diff --git a/dns/templates/zone.master.erb b/dns/templates/zone.master.erb new file mode 100644 index 0000000..1c9f557 --- /dev/null +++ b/dns/templates/zone.master.erb @@ -0,0 +1,11 @@ +zone "<%= zone %>" { + type master; + file "/etc/bind/db.<%= zone %>"; + <% if has_variable?('slaves') -%> + allow-transfer { + <% slaves.each do |slave| -%> + <%= slave['ipaddr'] %>; + <% end -%> + }; + <% end -%> +}; diff --git a/dns/templates/zone.slave.erb b/dns/templates/zone.slave.erb new file mode 100644 index 0000000..8e93a0d --- /dev/null +++ b/dns/templates/zone.slave.erb @@ -0,0 +1,9 @@ +zone "<%= zone %>" { + type slave; + file "/var/cache/bind/db.<%= zone %>"; + masters { + <% master.each do |m| -%> + <%= m['ipaddr'] %>; + <% end -%> + }; +};