logging/agent.pp: Allow one to specify logrotate rule for td-agent
This commit allows one to specify a logrotate rule to manage logging agent log. Close #625
This commit is contained in:
parent
8481286a93
commit
f4f95b563d
@ -63,6 +63,9 @@ fixtures:
|
||||
'fluentd':
|
||||
repo: 'git://github.com/enovance/puppet-fluentd.git'
|
||||
ref: 'd073a97002c569d8bfc38ac814ee33ed2cb13ca6'
|
||||
'logrotate':
|
||||
repo: 'git://github.com/enovance/puppet-logrotate.git'
|
||||
ref: 'f4d12356301fa2992f51dc7225037bb07556cb28'
|
||||
'haproxy':
|
||||
repo: 'git://github.com/enovance/puppetlabs-haproxy.git'
|
||||
ref: 'fc1166f28d411dfd4f59d4bfd6936595c014a11b'
|
||||
|
@ -113,6 +113,9 @@ mod 'kwalify',
|
||||
mod 'libvirt',
|
||||
:git => 'git://github.com/enovance/puppetlabs-libvirt.git',
|
||||
:ref => '05808874715ca3e899861a0af139e6a48255d3cb'
|
||||
mod 'logrotate',
|
||||
:git => 'git://github.com/enovance/puppet-logrotate.git',
|
||||
:ref => 'f4d12356301fa2992f51dc7225037bb07556cb28'
|
||||
mod 'memcached',
|
||||
:git => 'git://github.com/enovance/puppet-memcached.git',
|
||||
:ref => 'd009260de3c7623003318555ec5ca61217ea3ca1'
|
||||
|
@ -35,12 +35,17 @@
|
||||
# (optional) Fluentd plugins to install
|
||||
# Defaults to empty hash
|
||||
#
|
||||
# [*logrotate_rule*]
|
||||
# (optional) A log rotate rule for the logging agent
|
||||
# Defaults to empty hash
|
||||
#
|
||||
class cloud::logging::agent(
|
||||
$syslog_enable = false,
|
||||
$sources = {},
|
||||
$matches = {},
|
||||
$plugins = {},
|
||||
){
|
||||
$syslog_enable = false,
|
||||
$sources = {},
|
||||
$matches = {},
|
||||
$plugins = {},
|
||||
$logrotate_rule = $cloud::params::logging_agent_logrotate_rule,
|
||||
) inherits cloud::params {
|
||||
|
||||
include cloud::logging
|
||||
|
||||
@ -63,5 +68,6 @@ class cloud::logging::agent(
|
||||
create_resources('fluentd::source', $sources, {'require' => 'File[/var/db/td-agent]', 'notify' => 'Service[td-agent]'})
|
||||
create_resources('fluentd::match', $matches, {'notify' => 'Service[td-agent]'})
|
||||
create_resources('fluentd::install_plugin', $plugins)
|
||||
create_resources('logrotate::rule', $logrotate_rule)
|
||||
|
||||
}
|
||||
|
39
manifests/params.pp
Normal file
39
manifests/params.pp
Normal file
@ -0,0 +1,39 @@
|
||||
#
|
||||
# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# == Class: cloud::params
|
||||
#
|
||||
# Configure set of default parameters
|
||||
#
|
||||
class cloud::params {
|
||||
|
||||
# cloud::logging::agent
|
||||
$logging_agent_logrotate_rule = {
|
||||
'td-agent' => {
|
||||
'path' => '/var/log/td-agent/td-agent.log',
|
||||
'rotate' => 30,
|
||||
'compress' => true,
|
||||
'delaycompress' => true,
|
||||
'ifempty' => false,
|
||||
'create' => true,
|
||||
'create_mode' => '640',
|
||||
'create_owner' => 'td-agent',
|
||||
'create_group' => 'td-agent',
|
||||
'sharedscripts' => true,
|
||||
'postrotate' => ['pid=/var/run/td-agent/td-agent.pid', 'test -s $pid && kill -USR1 "$(cat $pid)"'],
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -28,11 +28,19 @@ describe 'cloud::logging::agent' do
|
||||
end
|
||||
|
||||
let :common_params do {
|
||||
:server => '127.0.0.1',
|
||||
:sources => {
|
||||
:plugins => {},
|
||||
:matches => {},
|
||||
:sources => {
|
||||
'apache' => {'type' => 'tail', 'configfile' => 'apache'},
|
||||
'syslog' => {'type' => 'tail', 'configfile' => 'syslog'}
|
||||
}
|
||||
},
|
||||
:logrotate_rule => {
|
||||
'td-agent' => {
|
||||
'path' => '/var/log/td-agent/td-agent.log',
|
||||
'rotate' => '30',
|
||||
'compress' => 'true',
|
||||
}
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
@ -80,6 +88,42 @@ describe 'cloud::logging::agent' do
|
||||
:group => 'td-agent',
|
||||
})
|
||||
end
|
||||
|
||||
it 'has a logrotate rule for td-agent.log' do
|
||||
it should contain_logrotate__rule('td-agent').with({
|
||||
:path => '/var/log/td-agent/td-agent.log',
|
||||
:rotate => '30',
|
||||
:compress => 'true',
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'logrotate rule with default parameters' do
|
||||
|
||||
it 'has a logrotate rule for td-agent.log' do
|
||||
it should contain_logrotate__rule('td-agent').with({
|
||||
:path => '/var/log/td-agent/td-agent.log',
|
||||
:rotate => '30',
|
||||
:compress => 'true',
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'logrotate rule with custom parameters' do
|
||||
let :params do
|
||||
common_params.merge!( {:logrotate_rule => { 'td-agent' => { 'path' => '/foo/bar', 'rotate' => '5', 'compress' => 'false'} }} )
|
||||
end
|
||||
|
||||
it 'has a logrotate rule for td-agent.log' do
|
||||
it should contain_logrotate__rule('td-agent').with({
|
||||
:path => '/foo/bar',
|
||||
:rotate => '5',
|
||||
:compress => 'false',
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user