Make rsyslog file_input bulletproof
This patch makes rsyslog::file_input accept also $sources as single hash. Currently when $sources is not array deployment fails. Change-Id: I91d9f8ffb1e0c8bbdbc90696950aafd797ff380c
This commit is contained in:
parent
249f907340
commit
8c813bc8ac
|
@ -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) '
|
$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 {
|
if $sources {
|
||||||
$rsyslog_sources = $sources.reduce([]) |$memo, $config| {
|
$sources_array = Array($sources, true)
|
||||||
|
$rsyslog_sources = $sources_array.reduce([]) |$memo, $config| {
|
||||||
if ! $config['startmsg.regex'] {
|
if ! $config['startmsg.regex'] {
|
||||||
$record = $config + {'startmsg.regex' => $default_startmsg}
|
$record = $config + {'startmsg.regex' => $default_startmsg}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -24,17 +24,17 @@ describe 'tripleo::profile::base::logging::rsyslog::file_input' do
|
||||||
'include rsyslog::server'
|
'include rsyslog::server'
|
||||||
end
|
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
|
shared_examples_for 'tripleo::profile::base::logging::rsyslog::file_input' do
|
||||||
context 'with basic parameters to configure rsyslog file inputs' 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
|
it 'should configure the given file inputs' do
|
||||||
should contain_concat__fragment('rsyslog::component::input::foobar_foo').with({
|
should contain_concat__fragment('rsyslog::component::input::foobar_foo').with({
|
||||||
:target => '/etc/rsyslog.d/50_rsyslog.conf',
|
:target => '/etc/rsyslog.d/50_rsyslog.conf',
|
||||||
|
@ -46,6 +46,21 @@ describe 'tripleo::profile::base::logging::rsyslog::file_input' do
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
on_supported_os.each do |os, facts|
|
on_supported_os.each do |os, facts|
|
||||||
|
|
Loading…
Reference in New Issue