Browse Source

Merge "Make rsyslog file_input bulletproof" into stable/train

changes/95/704495/1
Zuul Gerrit Code Review 1 month ago
parent
commit
c2c634ef07
2 changed files with 26 additions and 10 deletions
  1. +2
    -1
      manifests/profile/base/logging/rsyslog/file_input.pp
  2. +24
    -9
      spec/defines/tripleo_profile_base_logging_rsyslog_file_input_spec.rb

+ 2
- 1
manifests/profile/base/logging/rsyslog/file_input.pp View File

@@ -17,7 +17,8 @@ define tripleo::profile::base::logging::rsyslog::file_input (
$default_startmsg = '^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}(.[0-9]+ [0-9]+)? (DEBUG|INFO|WARNING|ERROR) '
) {
if $sources {
$rsyslog_sources = $sources.reduce([]) |$memo, $config| {
$sources_array = Array($sources, true)
$rsyslog_sources = $sources_array.reduce([]) |$memo, $config| {
if ! $config['startmsg.regex'] {
$record = $config + {'startmsg.regex' => $default_startmsg}
} else {


+ 24
- 9
spec/defines/tripleo_profile_base_logging_rsyslog_file_input_spec.rb View File

@@ -24,17 +24,17 @@ describe 'tripleo::profile::base::logging::rsyslog::file_input' do
'include ::rsyslog::server'
end

let :params do {
'sources' => [
{'file' => '/path/to/foo.log', 'tag' => 'foo'},
{'file' => '/path/to/bar.log', 'tag' => 'bar', 'startmsg.regex' => 'baz'}
],
'default_startmsg' => 'test'
}
end

shared_examples_for 'tripleo::profile::base::logging::rsyslog::file_input' do
context 'with basic parameters to configure rsyslog file inputs' do
let :params do {
'sources' => [
{'file' => '/path/to/foo.log', 'tag' => 'foo'},
{'file' => '/path/to/bar.log', 'tag' => 'bar', 'startmsg.regex' => 'baz'}
],
'default_startmsg' => 'test'
}
end

it 'should configure the given file inputs' do
should contain_concat__fragment('rsyslog::component::input::foobar_foo').with({
:target => '/etc/rsyslog.d/50_rsyslog.conf',
@@ -46,6 +46,21 @@ describe 'tripleo::profile::base::logging::rsyslog::file_input' do
})
end
end

context 'with non-array sources to configure rsyslog file input' do
let :params do {
'sources' => {'file' => '/path/to/foo.log', 'tag' => 'foo'},
'default_startmsg' => 'test'
}
end

it 'should configure the given file inputs' do
should contain_concat__fragment('rsyslog::component::input::foobar_foo').with({
:target => '/etc/rsyslog.d/50_rsyslog.conf',
:content => foo_log_conf,
})
end
end
end

on_supported_os.each do |os, facts|


Loading…
Cancel
Save