Skip to content
Snippets Groups Projects
Commit faacbec2 authored by Thomas Bellman's avatar Thomas Bellman
Browse files

Make syslog::modload deal with RainerScript.

Newer versions of rsyslog, a "scripting language" for configuring
rsyslog, named RainerScript, has been introduced, with version 6
the first version with full support.  RainerScript has a new way
of loading (and configuring) modules: ``module(load="NAME" ...)''
replaces the old $ModLoad directive.  The old syntax still works,
and you can mix them (and there are some features as of yet only
available using the old-style ``$'' directives).

We want to be able to use the new-style declarations, so we need
to adapt the syslog::modload definition to at least cope with the
new syntax in existing files and not add $ModLoad directives if
there is already a module() directive for the same module.  And
also be able to delete module() directives for ensure=>absent.

For the time being, we only change syslog::modload to recognize
the new syntax when it exists in the file, and if we need to add
a loading directive, the old syntax will be used, to support older
versions of rsyslog.

Our implementation is also quite limited in how module() directives
may be formatted to be handled properly.  In particular, the entire
directive must be contained on a single line to be removed correctly;
if not, the resulting file will have broken syntax.  module() direc-
tives must also start at the first column to be recognized.
parent 9c261280
No related branches found
No related tags found
No related merge requests found
# Add or remove $ModLoad directives from the rsyslog configuration.
#
# NOTE! For new-style (RainerScript) module(load="...") directives,
# this definition requires them to be on a single line, and start
# at the first column of the line.
#
# For the time being, only old-style $ModLoad directives will be
# added.
define syslog::modload($ensure='present')
{
# Accept either ``$ModLoad'' or ``module(load="..." ...)'' directive.
# For the module() case, don't require the closing paren, as there
# may be parameters on subsequent lines; this will avoid adding a
# load directive if one already exists, even if not fully contained
# on a single line, but for removing (ensure=>absent), we will create
# broken syntax, as only the line with ``module('' will be removed,
# and not the line with the closing paren. Better than nothing...
#
$modload_re = sprintf(
'^\$[Mm][Oo][Dd][Ll][Oo][Aa][Dd]\s+%s(\s*#.*)?$', $name
'^(\$[Mm][Oo][Dd][Ll][Oo][Aa][Dd]\s+%s(\s*#.*)?|module\(load="%s".*)$',
$name, $name
)
case $ensure
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment