Page MenuHomePhabricator

rsyslog::conf puppet define types inserts an extraneous newline in the content param
Closed, ResolvedPublicBUG REPORT

Description

Example

rsyslog::conf { 'postfix':
    priority => 20,
    content  => @(EOF),
        # Managed by Puppet
        # rsyslog.conf(5) config
        if ($programname startswith 'postfix') then {
            action(type="omfile" file="/var/log/postfix.log")
        }
        | EOF
}

Output

# Managed by Puppet

# rsyslog.conf(5) config
if ($programname startswith 'postfix') then {
    action(type="omfile" file="/var/log/postfix.log")
}

The extra newline after the first line is added due to this code:

# append a trailing newline if omitted
$content_formatted = $content ? {
    undef   => undef,
    default => regsubst($content, "\n?$", "\n")
}

$ matches the end of a *line* without the newline, so the regsubst always matches the first line whether it has a trailing newline or not.

Event Timeline

Change 841583 had a related patch set uploaded (by JHathaway; author: JHathaway):

[operations/puppet@production] rsyslog::conf remove trailing newline logic

https://gerrit.wikimedia.org/r/841583

Change 841583 merged by JHathaway:

[operations/puppet@production] rsyslog::conf remove trailing newline logic

https://gerrit.wikimedia.org/r/841583