From eb13310d12adfef0c7b2332b7129449dd6a64646 Mon Sep 17 00:00:00 2001 From: Steve Shipway Date: Tue, 25 Feb 2020 15:01:46 +1300 Subject: [PATCH] Allow configuration of logging options --- manifests/server/conf.pp | 16 ++++++++++++++++ templates/named.conf.erb | 24 ++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/manifests/server/conf.pp b/manifests/server/conf.pp index 7944be2ee..a879790e6 100644 --- a/manifests/server/conf.pp +++ b/manifests/server/conf.pp @@ -62,6 +62,8 @@ # and the value is an array of config lines. Default: empty # $includes: # Array of absolute paths to named.conf include files. Default: empty +# $logging: +# Hash containing channel: hash of channels, and category: hash of categroies # # Sample Usage : # bind::server::conf { '/etc/named.conf': @@ -88,6 +90,19 @@ # 'secret "aaabbbcccddd"', # ], # } +# logging => { +# channel => { +# foo => [ +# ' file "/var/named/foo"', +# 'severity info' +# ] +# }, +# category => { +# default => [ +# 'foo' +# ] +# } +# } # } # define bind::server::conf ( @@ -121,6 +136,7 @@ $keys = {}, $includes = [], $views = {}, + $logging = {}, ) { # OS Defaults diff --git a/templates/named.conf.erb b/templates/named.conf.erb index 39cd72b8c..49cb43917 100644 --- a/templates/named.conf.erb +++ b/templates/named.conf.erb @@ -101,6 +101,28 @@ options { bindkeys-file "/etc/named.iscdlv.key"; }; +<% if !@logging.empty? -%> +logging { +<% if @logging['channel'] and !@logging['channel'].empty? -%> +<% @logging['channel'].sort_by {|key,value| key}.each do |key,value| -%> + channel <%= key %> { +<% value.each do |line| -%> + <%= line %>; +<% end -%> + } +<% end -%> +<% end -%> +<% if @logging['category'] -%> +<% @logging['category'].sort_by {|key,value| key}.each do |key,value| -%> +<% if !value.empty? -%> + category <%= key %> { <%= value.join('; ') %>; }; +<% else -%> + category <%= key %> { }; +<% end -%> +<% end -%> +<% end -%> +}; +<% else -%> logging { channel main_log { file "/var/log/named/named.log" versions 3 size 5m; @@ -116,6 +138,8 @@ logging { null; }; }; +<% end -%> + <% if !@views.empty? -%> <% @views.sort_by {|key,value| key}.each do |key,value| -%>