Fluentd: fixed configuration by service

The configuration file by service was not
properly configured.

Also clean some double tasks on the tests

Change-Id: I3149902401d68d6fd236073a73a20f982d4b952a
Closes-Bug: #1746952
Related-Bug: #1715187
This commit is contained in:
Juan Badia Payno 2018-01-30 07:59:50 +01:00
parent 42e7ab0299
commit 42a869fcf4
2 changed files with 27 additions and 23 deletions

View File

@ -30,7 +30,7 @@ define tripleo::profile::base::logging::fluentd::fluentd_service (
# stub config files.
if !empty($sources) or !empty($filters) or !empty($matches) {
if $fluentd_transform and !empty($sources) {
$new_source = map($sources) |$source| {
$new_source = {} + map($sources) |$source| {
if $source['path'] {
$newpath = {
'path' => regsubst($source['path'],
@ -44,14 +44,12 @@ define tripleo::profile::base::logging::fluentd::fluentd_service (
}
}
}else{
$new_source = $sources
$new_source = {} + $sources
}
# Insert default values into list of sources.
$_sources = $new_source.map |$src| {
$default_source
+ {pos_file => "${pos_file_path}/${src['tag']}.pos"}
+ $src
}
$_sources = { 'pos_file' => "${pos_file_path}/${new_source['tag']}.pos" }
+ $default_source + $new_source
::fluentd::config { "100-openstack-${title}.conf":
config => {
'source' => $_sources,

View File

@ -119,8 +119,17 @@ describe 'tripleo::profile::base::logging::fluentd' do
) }
it { is_expected.to contain_fluentd__config('100-openstack-ceilometer_agent_central.conf') }
it { is_expected.to contain_file('/etc/fluentd/config.d/100-openstack-ceilometer_agent_central.conf').with_content(
/^\s*path \/var\/log\/ceilometer\/central\.log$/
"# This file is managed by Puppet, do not edit manually.
<source>
format /(?<time>\\d{4}-\\d{2}-\\d{2} \\d{2} =>\\d{2}:\\d{2}.\\d+) (?<pid>\\d+) (?<priority>\\S+) (?<message>.*)$/
path /var/log/ceilometer/central.log
pos_file /var/cache/fluentd//openstack.ceilometer.agent.central.pos
tag openstack.ceilometer.agent.central
@type tail
</source>
"
) }
end
context 'Config by service -- ceilometer_agent_central with path trasnformation' do
@ -141,19 +150,18 @@ describe 'tripleo::profile::base::logging::fluentd' do
:pos_file_path => '/var/cache/fluentd/',
:default_format => '/(?<time>\\d{4}-\\d{2}-\\d{2} \\d{2} =>\\d{2}:\\d{2}.\\d+) (?<pid>\\d+) (?<priority>\\S+) (?<message>.*)$/'
) }
it { is_expected.to contain_fluentd__config('100-openstack-ceilometer_agent_central.conf').with(
:config => {
'source' => [ {
'format' => '/(?<time>\\d{4}-\\d{2}-\\d{2} \\d{2} =>\\d{2}:\\d{2}.\\d+) (?<pid>\\d+) (?<priority>\\S+) (?<message>.*)$/',
'path' => '/var/log/containers/ceilometer/central.log',
'pos_file' => '/var/cache/fluentd//openstack.ceilometer.agent.central.pos',
'tag' => 'openstack.ceilometer.agent.central',
'type' => 'tail'
} ],
'filter' => [],
'match' => []
}
) }
it { is_expected.to contain_file('/etc/fluentd/config.d/100-openstack-ceilometer_agent_central.conf').with_content (
"# This file is managed by Puppet, do not edit manually.
<source>
format /(?<time>\\d{4}-\\d{2}-\\d{2} \\d{2} =>\\d{2}:\\d{2}.\\d+) (?<pid>\\d+) (?<priority>\\S+) (?<message>.*)$/
path /var/log/containers/ceilometer/central.log
pos_file /var/cache/fluentd//openstack.ceilometer.agent.central.pos
tag openstack.ceilometer.agent.central
@type tail
</source>
"
) }
end
context 'Groups by service -- ceilometer_agent_central added ceilometer' do
@ -188,7 +196,6 @@ describe 'tripleo::profile::base::logging::fluentd' do
:content => [ "# This file is maintained by puppet.\n[Service]\nUser=fluentd\n" ]
} ) }
it { is_expected.to contain_service('fluentd') }
it { is_expected.to contain_user('fluentd').with(
:ensure =>'present',
:groups => [ 'fluentd','ceilometer' ],
@ -214,7 +221,6 @@ describe 'tripleo::profile::base::logging::fluentd' do
:content => [ "# This file is maintained by puppet.\n[Service]\nUser=root\n" ]
} ) }
it { is_expected.to contain_service('fluentd') }
it { is_expected.to_not contain_user('fluentd') }
end