// This file is generated by Chef
// Do NOT edit it manually.

<%
acls = node['bind-grid']['acl']
acls.each {|name, cidrs|
-%>
acl "<%= name %>" {
<% cidrs.each {|cidr| %>
	<%= cidr %>;
<% } %>
};

<%
}
-%>
<%
extra_statements = node['bind-grid']['extra_statements']
unless extra_statements.empty?
-%>
<%= extra_statements %>

<%
end
-%>
options {
	directory "<%= node['bind-grid']['options']['directory'] %>";

	// If there is a firewall between you and nameservers you want
	// to talk to, you may need to fix the firewall to allow multiple
	// ports to talk.  See http://www.kb.cert.org/vuls/id/800113

	// If your ISP provided one or more IP addresses for stable 
	// nameservers, you probably want to use them as forwarders.  
	// Uncomment the following block, and insert the addresses replacing 
	// the all-0's placeholder.

	// forwarders {
	// 	0.0.0.0;
	// };

<%
listen_on_conf = node['bind-grid']['options']['listen-on']

ips = listen_on_conf['ipaddresses']
ips = [node['ipaddress']] if ips.empty?
-%>
	listen-on port <%= listen_on_conf['port'] %> {
		127.0.0.1;
<% ips.each {|ip| %>
		<%= ip %>;
<% } %>
	};
<%
listen_on_v6_conf = node['bind-grid']['options']['listen-on-v6']

ips = listen_on_v6_conf['ipaddresses']
ips = ['none'] if ips.empty?
-%>
	listen-on-v6 port <%= listen_on_conf['port'] %> {
<% ips.each {|ip| %>
		<%= ip %>;
<% } %>
	};

	//========================================================================
	// If BIND logs error messages about the root key being expired,
	// you will need to update your keys.  See https://www.isc.org/bind-keys
	//========================================================================
	dnssec-validation <%= node['bind-grid']['options']['dnssec-validation'] %>;

	auth-nxdomain <%= node['bind-grid']['options']['auth-nxdomain'] %>;    # conform to RFC1035
	//listen-on-v6 { any; };

	allow-query {
<% node['bind-grid']['options']['allow-query'].each {|id| %>
		<%= id %>;
<% } %>
	};

	recursion <%= node['bind-grid']['options']['recursion'] %>;
	allow-recursion {
<% node['bind-grid']['options']['allow-recursion'].each {|id| %>
		<%= id %>;
<% } %>
	};

	allow-transfer {
<%
allow_transfer = node['bind-grid']['options']['allow-transfer']
allow_transfer = ['none'] if allow_transfer.empty?
allow_transfer.each {|ip|
-%>
		<%= ip %>;
<% } %>
	};

	forwarders {
<% node['bind-grid']['options']['forwarders'].each {|ip| %>
		<%= ip %>;
<% } %>
	};
<%
extra_statements = node['bind-grid']['options']['extra_statements']
unless extra_statements.empty?
-%>
<%= extra_statements %>

<%
end
-%>
};
