-
Russ Allbery authored
Fix support for analyze_logs, which wasn't working due to the immutable variable problems with how Puppet uses ERB. Restructure the template to not precalculate the results, group lines for a particular log together, and format everything a bit better.
Russ Allbery authoredFix support for analyze_logs, which wasn't working due to the immutable variable problems with how Puppet uses ERB. Restructure the template to not precalculate the results, group lines for a particular log together, and format everything a bit better.
test-config 1.82 KiB
#!/usr/bin/ruby
#
# Test the config ERB template with the variables below.
require 'erb'
template = File.readlines('config.erb').join
# # Rotate /var/log/messages on local disk and analyze it.
# newsyslog::config { 'messages':
# frequency => 'daily',
# directory => '/var/log',
# restart => 'hup /var/run/syslogd.pid'
# log_owner => 'root',
# log_group => 'root',
# log_mode => 640,
# logs => [ 'messages' ],
# analyze => '/usr/bin/filter-syslog',
# save_num => '30',
# }
stop = ''
name = 'messages'
frequency = 'daily'
directory = '/var/log'
archive = ''
restart = 'hup /var/run/syslogd.pid'
log_owner = 'root'
log_group = 'root'
log_mode = '640'
logs = [ 'messages' ]
analyze = '/usr/bin/filter-syslog'
analyze_logs = []
save_num = '30'
message = ERB.new(template, 0, '-')
puts message.result
puts '=' * 76
# # Rotate Apache logs and save a copy into AFS.
# newsyslog::config { 'apache':
# frequency => 'daily',
# directory => '/var/log/apache2',
# archive => '/afs/ir/service/auth/logs/weblogin'
# restart => 'run /usr/sbin/apache2ctl graceful',
# log_owner => 'root',
# log_group => 'root',
# log_mode => 644,
# logs => [ 'access.log', 'error.log' ],
# analyze => '/usr/bin/filter-syslog /etc/webkdc/filter.conf',
# analyze_logs => [ 'error.log' ],
# }
save_num = '15'
name = 'apache'
frequency = 'daily'
directory = '/var/log/apache2'
archive = '/afs/ir/service/auth/logs/weblogin'
restart = 'run /usr/sbin/apache2ctl graceful'
log_owner = 'root'
log_group = 'root'
log_mode = '644'
logs = [ 'access.log', 'error.log' ]
analyze = '/usr/bin/filter-syslog /etc/webkdc/filter.conf'
analyze_logs = [ 'error.log' ]
message = ERB.new(template, 0, '-')
puts message.result