Skip to content

Commit 1ffc084

Browse files
author
Tatsuya Kawano
committed
Apply pull request fooforge#2 from @wohali to the upstream:
Support SmartOS, lists in attributes
1 parent 6e36014 commit 1ffc084

File tree

7 files changed

+115
-64
lines changed

7 files changed

+115
-64
lines changed

README.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,19 @@ Platform:
1717

1818
* Debian
1919
* Ubuntu
20-
* Centos
20+
* CentOS
21+
* SmartOS
2122

2223
Attributes
2324
==========
2425

2526
* **node[:bind9][:enable_ipv6]** - Enables BIND to listen on an IPv6 address. Default is: On
26-
* **node[:bind9][:allow_query]** - Allow clients to query the nameserver. Default is: anyone
27-
* **node[:bind9][:allow_recursion]** - Allow recursive name resolution. Default is: none (to prevent DNS cache poisoning)
28-
* **node[:bind9][:allow_update]** - Allow dynamic DNS updates. Default is: none
29-
* **node[:bind9][:allow_transfer]** - Allow zone transfers globally. Default is: none
27+
* **node[:bind9][:allow_query]** - Array of clients allowed to query the nameserver. Default is: anyone
28+
* **node[:bind9][:allow_recursion]** - Array of clients allowed to make recursive name resolution queries. Default is: none (to prevent DNS cache poisoning)
29+
* **node[:bind9][:allow_update]** - Array of clients allowed to make dynamic DNS updates. Default is: none
30+
* **node[:bind9][:allow_transfer]** - Array of clients allowed to make zone transfers. Default is: none
3031
* **node[:bind9][:enable_forwarding]** - Enables forwarding of requests. Default is: No forwarding
31-
* **node[:bind9][:forwarders]** - Array for forwarding DNS. Default is: 4.4.4.4 and 8.8.8.8 (Google DNS)
32+
* **node[:bind9][:forwarders]** - Array for forwarding DNS. Default is: 8.8.8.8 and 8.8.4.4 (Google DNS)
3233

3334
Usage
3435
=====
@@ -40,7 +41,18 @@ Please note that the data bag's structure is mandatory except:
4041
* autodomain for the zone (if you include this, automatic records will be added for chef nodes whose "domain" matches this)
4142

4243

43-
Examples
44+
Example attributes for a caching-only setup
45+
=====
46+
47+
default[:bind9][:allow_query] = ["localnets", "localhost"]
48+
default[:bind9][:allow_recursion] = ["localnets", "localhost"]
49+
default[:bind9][:allow_transfer] = ["none"]
50+
default[:bind9][:allow_update] = nil
51+
default[:bind9][:enable_forwarding] = true
52+
default[:bind9][:forwarders] = ["8.8.8.8", "8.8.4.4"]
53+
54+
55+
Example zone setup
4456
=====
4557

4658
$ knife data bag create zones

attributes/default.rb

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,38 @@
11
default[:bind9][:enable_ipv6] = true
22

3-
# Allow all clients to query the nameserver, no recursion
4-
default[:bind9][:allow_query] = nil
5-
default[:bind9][:allow_recursion] = "none"
3+
# Allow only local clients to query the nameserver, with recursion
4+
default[:bind9][:allow_query] = ["localnets", "localhost"]
5+
default[:bind9][:allow_recursion] = ["localnets", "localhost"]
66

77
# Don:t allow to mess with zone files by default
8-
default[:bind9][:allow_transfer] = "none"
8+
default[:bind9][:allow_transfer] = ["none"]
99
default[:bind9][:allow_update] = nil
1010

11-
default[:bind9][:enable_forwarding] = false
12-
default[:bind9][:forwarders] = [ "4.4.4.4", "8.8.8.8" ]
11+
# default forwarders @ Google
12+
default[:bind9][:enable_forwarding] = true
13+
default[:bind9][:forwarders] = ["8.8.8.8", "8.8.4.4"]
1314

1415
case platform
1516
when "centos","redhat","fedora","scientific","amazon"
1617
default[:bind9][:config_path] = "/etc/named"
17-
default[:bind9][:config_file] = "/etc/named.conf"
18-
default[:bind9][:options_file] = "/etc/named/named.conf.options"
19-
default[:bind9][:local_file] = "/etc/named/named.conf.local"
20-
default[:bind9][:data_path] = "/var/named"
18+
default[:bind9][:config_file] = "/etc/named.conf"
19+
default[:bind9][:options_file] = "/etc/named/named.conf.options"
20+
default[:bind9][:local_file] = "/etc/named/named.conf.local"
21+
default[:bind9][:data_path] = "/var/named"
22+
default[:bind9][:log_path] = "/var/log/bind"
2123
default[:bind9][:user] = "named"
24+
when "smartos"
25+
default[:bind9][:config_path] = "/opt/local/etc"
26+
default[:bind9][:options_file] = "/opt/local/etc/named.conf.options"
27+
default[:bind9][:local_file] = "/opt/local/etc/named.conf.local"
28+
default[:bind9][:data_path] = "/var/named"
29+
default[:bind9][:log_path] = "/var/log/named"
30+
default[:bind9][:user] = "root"
2231
else
2332
default[:bind9][:config_path] = "/etc/bind"
24-
default[:bind9][:options_file] = "/etc/bind/named.conf.options"
25-
default[:bind9][:local_file] = "/etc/bind/named.conf.local"
26-
default[:bind9][:data_path] = "/var/cache/bind"
33+
default[:bind9][:options_file] = "/etc/bind/named.conf.options"
34+
default[:bind9][:local_file] = "/etc/bind/named.conf.local"
35+
default[:bind9][:data_path] = "/var/cache/bind"
36+
default[:bind9][:log_path] = "/var/log/named"
2737
default[:bind9][:user] = "bind"
2838
end

metadata.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
66
version "0.1.9"
77

8-
%w{ ubuntu debian centos }.each do |os|
8+
%w{ ubuntu debian centos smartos }.each do |os|
99
supports os
1010
end

recipes/default.rb

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,41 @@
1919

2020
package "bind9" do
2121
case node[:platform]
22-
when "centos", "redhat", "suse", "fedora"
22+
when "centos", "redhat", "suse", "fedora", "smartos"
2323
package_name "bind"
2424
end
2525
action :install
2626
end
2727

28-
directory "/var/log/bind/" do
28+
directory node[:bind9][:log_path] do
2929
owner node[:bind9][:user]
3030
group node[:bind9][:user]
31-
mode 0755
31+
mode 0775
32+
recursive true
33+
action :create
3234
end
3335

3436
service "bind9" do
3537
case node[:platform]
3638
when "centos", "redhat"
3739
service_name "named"
40+
when "smartos"
41+
service_name "dns/server:default"
3842
end
3943
supports :status => true, :reload => true, :restart => true
4044
action [ :enable ]
4145
end
4246

47+
if node[:platform] == "smartos"
48+
template "#{node[:bind9][:config_path]}/named.conf" do
49+
source "named.conf.erb"
50+
owner "root"
51+
group "root"
52+
mode 0644
53+
notifies :restart, resources(:service => "bind9")
54+
end
55+
end
56+
4357
template node[:bind9][:options_file] do
4458
source "named.conf.options.erb"
4559
owner "root"

templates/default/named.conf.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
include "<%= node[:bind9][:config_path] %>/named.conf.options";
2+
include "<%= node[:bind9][:config_path] %>/named.conf.local";
3+
// include "<%= node[:bind9][:config_path] %>/named.conf.default-zones";

templates/default/named.conf.local.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<% @zonefiles.each do |conf| -%>
1010
zone "<%= conf["domain"] %>" IN {
1111
type <%= conf["type"] %>;
12-
file "<%= node[:bind9][:config_path] %>/<%= conf["domain"] %>";
12+
file "<%= conf["domain"] %>";
1313
allow-transfer {
1414
<% conf["allow_transfer"].each do |ip| -%>
1515
<%= ip %>;

templates/default/named.conf.options.erb

Lines changed: 51 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,59 @@
11
options {
2-
directory "<%= node[:bind9][:data_path] %>";
3-
4-
// If there is a firewall between you and nameservers you want
5-
// to talk to, you may need to fix the firewall to allow multiple
6-
// ports to talk. See http://www.kb.cert.org/vuls/id/800113
7-
8-
<% if node[:bind9][:allow_query] %>
9-
allow-query {
10-
"<%= node[:bind9][:allow_query] %>";
11-
};
12-
13-
<% end %>
14-
allow-recursion {
15-
<%= node[:bind9][:allow_recursion] %>;
16-
};
17-
18-
allow-transfer {
19-
"<%= node[:bind9][:allow_transfer] %>";
20-
};
21-
22-
<% if node[:bind9][:allow_update] %>
23-
allow-update {
24-
"<%= node[:bind9][:allow_update] %>";
25-
};
26-
27-
<% end %>
28-
<% if node[:bind9][:enable_forwarding] %>
29-
forwarders {
30-
<% node[:bind9][:forwarders].each do |forwarder| -%>
31-
<%= forwarder %>;
32-
<% end %>
33-
};
34-
35-
<% end %>
36-
auth-nxdomain no; # conform to RFC1035
37-
<% if node[:bind9][:enable_ipv6] %>
38-
listen-on-v6 { any; };
39-
<% end %>
2+
directory "<%= node[:bind9][:data_path] %>";
3+
4+
// If there is a firewall between you and nameservers you want
5+
// to talk to, you may need to fix the firewall to allow multiple
6+
// ports to talk. See http://www.kb.cert.org/vuls/id/800113
7+
8+
<% if node[:bind9][:allow_query] %>
9+
allow-query {
10+
<% node[:bind9][:allow_query].each do |allow_query| -%>
11+
<%= allow_query %>;
12+
<% end %>
13+
};
14+
15+
<% end %>
16+
<% if node[:bind9][:allow_recursion] %>
17+
allow-recursion {
18+
<% node[:bind9][:allow_recursion].each do |allow_recursion| -%>
19+
<%= allow_recursion %>;
20+
<% end %>
21+
};
22+
23+
<% end %>
24+
<% if node[:bind9][:allow_transfer] %>
25+
allow-transfer {
26+
<% node[:bind9][:allow_transfer].each do |allow_transfer| -%>
27+
<%= allow_transfer %>;
28+
<% end %>
29+
};
30+
31+
<% end %>
32+
<% if node[:bind9][:allow_update] %>
33+
allow-update {
34+
<% node[:bind9][:allow_update].each do |allow_update| -%>
35+
<%= allow_update %>;
36+
<% end %>
37+
};
38+
39+
<% end %>
40+
<% if node[:bind9][:enable_forwarding] %>
41+
forwarders {
42+
<% node[:bind9][:forwarders].each do |forwarder| -%>
43+
<%= forwarder %>;
44+
<% end %>
45+
};
46+
47+
<% end %>
48+
auth-nxdomain no; # conform to RFC1035
49+
<% if node[:bind9][:enable_ipv6] %>
50+
listen-on-v6 { any; };
51+
<% end %>
4052
};
4153

4254
logging {
4355
channel default_log {
44-
file "/var/log/bind/bind.log" versions 5 size 128M;
56+
file "<%= node[:bind9][:log_path] %>/named.log" versions 5 size 128M;
4557
print-time yes;
4658
print-severity yes;
4759
print-category yes;

0 commit comments

Comments
 (0)