Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for keys #50

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 2 additions & 2 deletions spec/classes/bind_server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
'hasstatus' => true,
'enable' => true,
'ensure' => 'running',
'restart' => '/sbin/service named reload'
'restart' => 'service named reload'
})}
it 'should create the logging directory' do
expect { should contain_file('/var/log/named').with({
Expand All @@ -22,4 +22,4 @@
})}
end

end
end
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