Skip to content
Snippets Groups Projects
Commit d3d102ed authored by Thomas Bellman's avatar Thomas Bellman Committed by Hans Persson
Browse files

Refactor handling of rsyslog $ModLoad directives.

Break out management of $ModLoad directives in rsyslog.conf from the
syslog-service__::centos class into a new defintion rsyslog::modload,
and call that from syslog-service__::centos.

This was originally commit 36c5a0013388 in intserv.
parent 8756dafa
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,45 @@ class syslog::vars
}
/*
* Add or remove $ModLoad directives from the rsyslog configuration.
*/
define rsyslog::modload($ensure='present')
{
$modload_re = sprintf(
'^\$[Mm][Oo][Dd][Ll][Oo][Aa][Dd]\s+%s(\s*#.*)?$', $name
)
case $ensure
{
'present': {
ensure_line {
"rsyslog::modload::${name}":
file => '/etc/rsyslog.conf',
line => "\$ModLoad ${name}",
sufficient => $modload_re,
addhow => prepend,
require => Package['rsyslog'],
notify => Service['rsyslog'];
}
}
'absent': {
delete_lines {
"rsyslog::modload::${name}":
file => '/etc/rsyslog.conf',
pattern => $modload_re,
require => Package['rsyslog'],
notify => Service['rsyslog'];
}
}
default: {
fail("Rsyslog::Modload[${title}]:",
" Bad parameter ensure, \"${ensure}\"")
}
}
}
class syslog-service__::centos
{
package {
......@@ -17,21 +56,9 @@ class syslog-service__::centos
ensure => installed,
notify => Service['rsyslog'];
}
ensure_line {
syslog-get-kernel-messages:
file => '/etc/rsyslog.conf',
line => '$ModLoad imklog',
pattern => '^\$[Mm][Oo][Dd][Ll][Oo][Aa][Dd] +imklog *$',
addhow => prepend,
require => Package['rsyslog'],
notify => Service['rsyslog'];
syslog-get-local-messages:
file => '/etc/rsyslog.conf',
line => '$ModLoad imuxsock',
pattern => '^\$[Mm][Oo][Dd][Ll][Oo][Aa][Dd] +imuxsock *$',
addhow => prepend,
require => Package['rsyslog'],
notify => Service['rsyslog'];
rsyslog::modload {
'imklog': ensure => present;
'imuxsock': ensure => present;
}
service {
'rsyslog':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment