Skip to content

Commit

Permalink
add support for keys
Browse files Browse the repository at this point in the history
  • Loading branch information
Seth Lyons authored and sethlyons committed Jul 29, 2015
1 parent c7417a7 commit b30551b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
3 changes: 3 additions & 0 deletions manifests/server/conf.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down Expand Up @@ -107,6 +109,7 @@
$zones = {},
$includes = [],
$views = {},
$keys = {},
) {

# Everything is inside a single template
Expand Down
30 changes: 26 additions & 4 deletions templates/named.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ acl <%= key %> {
<%= line %>;
<% end -%>
};
<% end -%>
<% end -%>

<% if [email protected]? -%>
<% @keys.sort_by {|key, value| key}.each do |key,value| -%>
key <%= key %> {
<% value.each do |k, v| -%>
<%= k %> "<%= v %>";
<% end -%>
};

<% end -%>
<% end -%>
Expand Down Expand Up @@ -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 -%>
Expand Down Expand Up @@ -105,7 +118,7 @@ logging {
};
<% if [email protected]? -%>

<% @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| -%>
Expand All @@ -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| -%>
Expand Down

0 comments on commit b30551b

Please sign in to comment.