Implement support for logging configuration
Adds `bind::logging::channel` and `bind::logging::category` defines in order to support logging configuration.
This commit is contained in:
@@ -5,6 +5,7 @@ class bind::defaults (
|
||||
$confdir = undef,
|
||||
$namedconf = undef,
|
||||
$cachedir = undef,
|
||||
$logdir = undef,
|
||||
$random_device = undef,
|
||||
$bind_user = undef,
|
||||
$bind_group = undef,
|
||||
|
||||
@@ -79,6 +79,7 @@ class bind (
|
||||
"${confdir}/keys.conf",
|
||||
"${confdir}/views.conf",
|
||||
"${confdir}/servers.conf",
|
||||
"${confdir}/logging.conf",
|
||||
"${confdir}/view-mappings.txt",
|
||||
"${confdir}/domain-mappings.txt",
|
||||
]:
|
||||
@@ -90,6 +91,18 @@ class bind (
|
||||
notify => Service['bind'],
|
||||
}
|
||||
|
||||
concat::fragment { 'bind-logging-header':
|
||||
order => "00-header",
|
||||
target => "${confdir}/logging.conf",
|
||||
content => "logging {\n";
|
||||
}
|
||||
|
||||
concat::fragment { 'bind-logging-footer':
|
||||
order => "99-footer",
|
||||
target => "${confdir}/logging.conf",
|
||||
content => "};\n";
|
||||
}
|
||||
|
||||
service { 'bind':
|
||||
ensure => running,
|
||||
name => $bind_service,
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
# ex: syntax=puppet si ts=4 sw=4 et
|
||||
|
||||
define bind::logging::category (
|
||||
$channels
|
||||
) {
|
||||
concat::fragment { "bind-logging-category-${name}":
|
||||
order => "60-${name}",
|
||||
target => "${::bind::confdir}/logging.conf",
|
||||
content => inline_template("\tcategory <%= @name %> {\n<% Array(@channels).each { |c| %>\t\t<%= c %>;\n<% } %>\t};\n"),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
# ex: syntax=puppet si ts=4 sw=4 et
|
||||
|
||||
define bind::logging::channel (
|
||||
$destination = 'file',
|
||||
$file_path = $::bind::defaults::logdir,
|
||||
$file_name = '',
|
||||
$syslog_facility = '',
|
||||
$severity = '',
|
||||
$print_category = true,
|
||||
$print_severity = true,
|
||||
$print_time = true,
|
||||
) {
|
||||
unless member(['file', 'syslog', 'stderr', 'null'], $destination) {
|
||||
fail("Bind::logging::channel[${name}] has invalid destination: ${destionation}. Must be one of: file syslog stderr null")
|
||||
}
|
||||
|
||||
if $destination == 'file' {
|
||||
unless defined(File[$file_path]) {
|
||||
file { $file_path:
|
||||
ensure => directory,
|
||||
owner => $::bind::bind_user,
|
||||
group => $::bind::bind_group,
|
||||
mode => '0640',
|
||||
}
|
||||
}
|
||||
|
||||
if $file_name == '' {
|
||||
fail("Bind::logging::channel[${name}] must specify file_name when using file destination")
|
||||
}
|
||||
}
|
||||
|
||||
if $destination == 'syslog' {
|
||||
unless member(['AUTH', 'AUTHPRIV', 'CRON', 'DAEMON', 'FTP', 'KERN', 'LOCAL0',
|
||||
'LOCAL1', 'LOCAL2', 'LOCAL3', 'LOCAL4', 'LOCAL5', 'LOCAL6', 'LOCAL7',
|
||||
'LPR', 'MAIL', 'NEWS', 'SYSLOG', 'USER', 'UUCP'], $syslog_facility) {
|
||||
file("Bind::logging::channell[${name}] has invalid syslog_facility: ${syslog_facility}.")
|
||||
}
|
||||
}
|
||||
|
||||
unless $severity == '' or member(['critical', 'error', 'warning', 'notice', 'info', 'debug', 'dynamic'], $severity) {
|
||||
fail("Bind::logging::channel[${name}] has invalid severity: ${severity}")
|
||||
}
|
||||
|
||||
concat::fragment { "bind-logging-channel-${name}":
|
||||
order => "40-${name}",
|
||||
target => "${::bind::confdir}/logging.conf",
|
||||
content => template('bind/logging_channel.erb'),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user