From 5f10663dc6676b096b58354347d87e77714b1cc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Mon, 20 Jan 2014 16:10:18 +0100 Subject: [PATCH] fix bind cookboofix bind cookbookk --- roles/head_node.json | 2 +- site-cookbooks/bind/recipes/default.rb | 7 +++++-- site-cookbooks/bind/templates/default/named.conf.erb | 3 ++- site-cookbooks/bind/templates/default/zone.erb | 5 ++++- spec/coobooks/bind_spec.rb | 7 +++---- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/roles/head_node.json b/roles/head_node.json index d6f98c9..64aa736 100644 --- a/roles/head_node.json +++ b/roles/head_node.json @@ -19,7 +19,7 @@ "lctp": { "records": [{ "name": "node1", "type": "A", "value": "172.28.128.101" }] }, - "128.28.172.in-addr": { + "128.28.172.in-addr.arpa": { "records": [{ "name": "101", "type": "PTR", "value": "node1" }] } }, diff --git a/site-cookbooks/bind/recipes/default.rb b/site-cookbooks/bind/recipes/default.rb index 6f17733..658a725 100644 --- a/site-cookbooks/bind/recipes/default.rb +++ b/site-cookbooks/bind/recipes/default.rb @@ -26,10 +26,13 @@ node.bind.zones.each do |name, zone| action :nothing end - template "/var/cache/bind/#{name}.zone" do + template "/etc/bind/#{name}" do source "zone.erb" + mode "0660" + owner "root" + owner "bind" notifies :run, "execute[update #{name} zone]" - variables(zone: zone, zone_name: name) + variables(zone: zone, zone_name: name, node: node) end end diff --git a/site-cookbooks/bind/templates/default/named.conf.erb b/site-cookbooks/bind/templates/default/named.conf.erb index 3777071..188a674 100644 --- a/site-cookbooks/bind/templates/default/named.conf.erb +++ b/site-cookbooks/bind/templates/default/named.conf.erb @@ -5,6 +5,7 @@ include "/etc/bind/named.conf.default-zones"; <% @node.bind.zones.each do |name, zone| -%> zone <%= name %> IN { type master; - file "<%= name %>"; + file "/etc/bind/<%= name %>"; }; <% end -%> + diff --git a/site-cookbooks/bind/templates/default/zone.erb b/site-cookbooks/bind/templates/default/zone.erb index c316101..de41633 100644 --- a/site-cookbooks/bind/templates/default/zone.erb +++ b/site-cookbooks/bind/templates/default/zone.erb @@ -4,7 +4,10 @@ 4H ; retry 3W ; expire 1D ) ; minimun + NS <%= @node.hostname %> + +<%= @node.hostname %> A <%= @node.ipaddress %> <% @zone.records.each do |record| -%> - <%= record.name %> <%= record.type %> <%= record.value %> +<%= record.name %> <%= record.type %> <%= record.value %> <% end -%> diff --git a/spec/coobooks/bind_spec.rb b/spec/coobooks/bind_spec.rb index fa004e3..02d953c 100644 --- a/spec/coobooks/bind_spec.rb +++ b/spec/coobooks/bind_spec.rb @@ -8,7 +8,7 @@ describe 'bind::default' do "lctp" => { records: [{ name: "node1", type: "A", value: "172.28.128.101" }] }, - "128.28.172.in-addr" => { + "128.28.172.in-addr.arpa" => { records: [{ name: "101", type: "PTR", value: "node1" }] } }, @@ -20,9 +20,8 @@ describe 'bind::default' do it "should setup named" do chef_run.should render_file("/etc/bind/named.conf").with_content("lctp") chef_run.should render_file("/etc/bind/named.conf.options").with_content("8.8.8.8") - chef_run.should render_file("/var/cache/bind/lctp.zone").with_content("node1") - chef_run.should render_file("/var/cache/bind/128.28.172.in-addr.zone").with_content("node1") + chef_run.should render_file("/etc/bind/lctp").with_content("node1") + chef_run.should render_file("/etc/bind/128.28.172.in-addr.arpa").with_content("node1") chef_run.should install_package("bind9") - end end