diff --git a/manifests/server/conf.pp b/manifests/server/conf.pp index 1f11132fc..507d74f26 100644 --- a/manifests/server/conf.pp +++ b/manifests/server/conf.pp @@ -56,6 +56,8 @@ # and the value is an array of config lines. Default: empty # $includes: # Array of absolute paths to named.conf include files. Default: empty +# $keys: +# Array containing key parameters as key/value pairs # # Sample Usage : # bind::server::conf { '/etc/named.conf': @@ -107,6 +109,7 @@ $zones = {}, $includes = [], $views = {}, + $keys = {}, ) { # Everything is inside a single template diff --git a/templates/named.conf.erb b/templates/named.conf.erb index bce153ce2..7002a5730 100644 --- a/templates/named.conf.erb +++ b/templates/named.conf.erb @@ -10,6 +10,16 @@ acl <%= key %> { <%= line %>; <% end -%> }; +<% end -%> +<% end -%> + +<% if !@keys.empty? -%> +<% @keys.sort_by {|key, value| key}.each do |key,value| -%> +key <%= key %> { +<% value.each do |k, v| -%> + <%= k %> "<%= v %>"; +<% end -%> +}; <% end -%> <% end -%> @@ -69,14 +79,17 @@ options { allow-transfer { <%= @allow_transfer.join("; ") %>; }; <% end -%> <% if !@check_names.empty? -%> -<% @check_names.each do |line| -%> - check-names <%= line %>; -<% end -%> + check-names <%= @check_names.join(' ') %>; <% end -%> <% if !@extra_options.empty? -%> <% @extra_options.sort_by {|key, value| key}.each do |key,value| -%> + <%# Deal with options that don't play well as array elements %> + <% if key.eql?('also-notify') -%> + <%= key %> { <%= value.join('; ') %>; }; + <% else -%> <%= key %> <%= value %>; + <% end -%> <% end -%> <% end -%> @@ -105,7 +118,7 @@ logging { }; <% if !@views.empty? -%> -<% @views.sort_by {|key,value| key}.each do |key,value| -%> +<% @views.each do |key,value| -%> <% valid_keys = %w(allow-notify allow-query allow-recursion allow-transfer allow-update-forwarding forwarders match-clients match-destinations match-recursive-only) -%> view "<%= key %>" { <% valid_keys.sort.each do |valid_key| -%> @@ -118,6 +131,15 @@ view "<%= key %>" { include "<%= filename %>"; <% end -%> <% end -%> +<% if value['server'] and !value['server'].empty? -%> +<% value['server'].sort_by {|key, value| key}.each do |key,value| -%> + server <%= key %> { +<% value.each do |line| -%> + <%= line %>; +<% end -%> + }; +<% end -%> +<% end -%> <% if value['zones'] and !value['zones'].empty? -%> /* View specific zones */ <% value['zones'].sort_by {|key, value| key}.each do |key,value| -%>