From 265a13a8e5166ca4cd4cecbf64cb8229e3dcd106 Mon Sep 17 00:00:00 2001 From: Lars Kellogg-Stedman Date: Mon, 11 Sep 2017 10:00:18 -0600 Subject: Allow log path transformation in fluentd glue Logs in a containerized deployment are not in the same location as on a baremetal deployment. This commit adds the $fluentd_path_transform paramter to the fluentd glue module. This is a regular expression that is used to transform log paths. To use this feature, include in your hiera configuration something like: tripleo::profile::base::logging::fluentd::fluentd_path_transform: - /var/log/ - /var/log/containers/ Change-Id: I585b6877074353b5de62e5efaabfbe62432c473d Partial-bug: #1716427 (cherry picked from commit 1ff0903a3950bc4adbc8c84b5153df6ca0fb6a3d) --- manifests/profile/base/logging/fluentd.pp | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/manifests/profile/base/logging/fluentd.pp b/manifests/profile/base/logging/fluentd.pp index b23610a..2e41942 100644 --- a/manifests/profile/base/logging/fluentd.pp +++ b/manifests/profile/base/logging/fluentd.pp @@ -58,6 +58,11 @@ # [*fluentd_syslog_port*] # (Optional, default 42185) Port on which fluentd should listen if # $fluentd_listen_syslog is true. +# +# [*fluentd_path_transform*] +# (Optional) List. Specifies [find, replace] arguments that will be +# used to transform the 'path' value for logging sources using puppet's +# regsubst function. class tripleo::profile::base::logging::fluentd ( $step = Integer(hiera('step')), $fluentd_sources = undef, @@ -69,7 +74,8 @@ class tripleo::profile::base::logging::fluentd ( $fluentd_ssl_certificate = undef, $fluentd_shared_key = undef, $fluentd_listen_syslog = true, - $fluentd_syslog_port = 42185 + $fluentd_syslog_port = 42185, + $fluentd_path_transform = undef ) { if $step >= 4 { @@ -98,9 +104,28 @@ class tripleo::profile::base::logging::fluentd ( } if $fluentd_sources { + + if $fluentd_path_transform { + $_fluentd_sources = map($fluentd_sources) |$source| { + if $source['path'] { + $newpath = { + 'path' => regsubst($source['path'], + $fluentd_path_transform[0], + $fluentd_path_transform[1]) + } + + $source + $newpath + } else { + $source + } + } + } else { + $_fluentd_sources = $fluentd_sources + } + ::fluentd::config { '100-openstack-sources.conf': config => { - 'source' => $fluentd_sources, + 'source' => $_fluentd_sources, } } } -- cgit 1.2.3-korg