// This file is generated by Chef
// Do NOT edit it manually.
//
// Do any local configuration here
//

// Consider adding the 1918 zones here, if they are not used in your
// organization
//include "/etc/bind/zones.rfc1918";

<%
role = node['bind-grid']['role']
masters = node['bind-grid']['zone']['masters']
allow_transfer = node['bind-grid']['zone']['allow-transfer']

node['bind-grid']['zone']['files'].sort.each {|zfile|
	zarray = zfile.split('.')
	zarray.shift
	zname = ''

	if zarray[0] =~ /^\d+$/
		zname = "#{zarray.reverse.join('.')}.in-addr.arpa"
	else
		zname = zarray.join('.')
	end

	case role
	when 'master'
-%>
zone "<%= zname %>" {
	type master;
	file "<%= zfile %>";
	allow-transfer {
<%
		allow_transfer.each {|ip|
-%>
		<%= ip %>;
<%
		}
-%>
	};
};

<%
	when 'slave'
-%>
zone "<%= zname %>" {
	type slave;
	masters {
<%
		masters.each {|ip|
-%>
		<%= ip %>;
<%
		}
-%>
	};
	file "<%= zfile %>";
};

<%
	end
}
-%>
