// named.conf

include "/etc/bind/designate-rndc.key";

controls  {
<%- scope.lookupvar('::dns::controls').sort_by {|k, v| k}.each do |control_ip, control_hash| -%>
        inet <%= control_ip %> port <%= control_hash['port'] %> allow { <% control_hash['allowed_addresses'].sort.each do |address| %><%= address %>; <% end %>} keys { <% control_hash['keys'].sort.each do |key| %>"<%= key %>"; <% end %>};
<%- end -%>
};

options  {
        include "<%= scope.lookupvar('::dns::optionspath') %>";
};

<% unless scope.lookupvar("::dns::enable_views") -%>
<% if scope.lookupvar("::dns::localzonepath") != 'unmanaged' -%>
include "<%= scope.lookupvar('::dns::localzonepath') %>";
<% end -%>
<% end -%>

<%- scope.lookupvar('::dns::acls').sort_by {|k, v| k}.each do |acl_name, acl_array| -%>
acl "<%= acl_name %>"  {
        <%- acl_array.sort.each do |subnet| -%>
        <%= subnet %>;
        <%- end -%>
};
<%- end -%>
<%- if scope.lookupvar('::dns::additional_directives').any? -%>
// additional directives
<%- scope.lookupvar('::dns::additional_directives').each do |directive| -%>
<%= directive %>
<%- end -%>
<%- end -%>

// Public view read by Server Admin
include "<%= scope.lookupvar('::dns::publicviewpath') %>";
