Skip to content

Add the ability to configure BIND logging. #57

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

Open
wants to merge 1 commit 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
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,29 @@ bind::server::conf {
}
```

You can use the `logging` parameter to configure logging:

```puppet
::bind::server::conf { '/etc/named.conf':
...
#Enable logging to /var/log/named/named.log
logging => {
'categories' => { 'default' => 'main_log', 'lame-servers' => 'null' },
'channels' => {
'main_log' => {
channel_type => 'file',
#This parameter only applies if the 'channel_type' is set to 'syslog':
facility => 'daemon',
#'file_location', 'versions' and 'size' only get applied if the 'channel_type' is set to 'file':
file_location => '/var/log/named/named.log',
versions => '3',
size => '5m',
severity => 'info',
print-time => 'yes',
print-severity => 'yes',
print-category => 'yes'
},
},
},
...
```
22 changes: 22 additions & 0 deletions manifests/server/conf.pp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
# $memstatistics_file:
# Memory statistics file for the server.
# Default: '/var/named/data/named_mem_stats.txt'
# $logging:
# A hash of hashes; one hash defines logging categories and the other defines logging
# channels. Defaults to sending BIND's default logs to /var/log/named/named.log, with rotations
# every 5MB and keeping 3 rotated logs.
# $allow_query:
# Array of IP addrs or ACLs to allow queries from. Default: [ 'localhost' ]
# $recursion:
Expand Down Expand Up @@ -94,6 +98,24 @@
$dump_file = '/var/named/data/cache_dump.db',
$statistics_file = '/var/named/data/named_stats.txt',
$memstatistics_file = '/var/named/data/named_mem_stats.txt',
$logging = {
'categories' => { 'default' => 'main_log', 'lame-servers' => 'null' },
'channels' => {
'main_log' => {
channel_type => 'file',
#This parameter only applies if the 'channel_type' is set to 'syslog':
facility => 'daemon',
#'file_location', 'versions' and 'size' only get applied if the 'channel_type' is set to 'file':
file_location => '/var/log/named/named.log',
versions => '3',
size => '5m',
severity => 'info',
print-time => 'yes',
print-severity => 'yes',
print-category => 'yes'
},
},
},
$allow_query = [ 'localhost' ],
$allow_query_cache = [],
$recursion = 'yes',
Expand Down
60 changes: 47 additions & 13 deletions templates/named.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,55 @@ options {
bindkeys-file "/etc/named.iscdlv.key";
};

<% if [email protected]? -%>
//This page has more info on BIND logging options: http://www.zytrax.com/books/dns/ch7/logging.html
logging {
channel main_log {
file "/var/log/named/named.log" versions 3 size 5m;
severity info;
print-time yes;
print-severity yes;
print-category yes;
};
category default{
main_log;
};
category lame-servers {
null;
};
<%- if @logging['categories'] and !@logging['categories'].empty? and @logging['categories'].is_a?(Hash) -%>
//These categories refer to built-in categories of log messages that BIND generates (what's
//next to 'category') and the user-defined channels they get sent to, which is inside of the {};
<% @logging['categories'].each do |builtin_bind_category, channel_name|-%>
category <%=builtin_bind_category%> {
<%=channel_name%>;
};
<% end -%>
<% end -%>
//Channels are user-defined log outputs (file or syslog) that receive log events from any
//categories specified above that reference the channel.
<%- if @logging['channels'] and !logging['channels'].empty? and @logging['channels'].is_a?(Hash) -%>
<%- @logging['channels'].each do |channel_name, channel_parameters|-%>
channel <%=channel_name-%> {
<%- if !channel_parameters['channel_type'].empty? -%>
<%- if channel_parameters['channel_type'] == 'file'-%>
//'versions' is the number of older logs we'll keep; size is how large the current log
//file will be allowed to grow before it gets rotated. File size units are defined as follows:
// k or K - Kilobytes
// m or M - Megabytes
// g or G - Gigabytes
//If the size is given as just a number, BIND will assume it specifies bytes.
//For example, 25000000 = 25m
<%=channel_parameters['channel_type']-%> "<%=channel_parameters['file_location']-%>" versions <%=channel_parameters['versions']-%> size <%=channel_parameters['size']-%>;
<%- elsif channel_parameters['channel_type'] == 'syslog'-%>
<%=channel_parameters['channel_type']-%> <%=channel_parameters['facility']-%>;
<%- end -%>
<%- if !channel_parameters['severity'].empty? -%>
severity <%=channel_parameters['severity']-%>;
<%- end -%>
<%- if !channel_parameters['print-time'].empty? -%>
print-time <%=channel_parameters['print-time']-%>;
<%- end -%>
<%- if !channel_parameters['print-severity'].empty? -%>
print-severity <%=channel_parameters['print-severity']-%>;
<%- end -%>
<%- if !channel_parameters['print-category'].empty? -%>
print-category <%=channel_parameters['print-category']-%>;
<%- end -%>
<%- end -%>
};
<%-end -%>
<%- end -%>
};
<% end -%>

<% if [email protected]? -%>

<% @views.sort_by {|key,value| key}.each do |key,value| -%>
Expand Down