2015-12-01 12:28:51 +00:00
|
|
|
# Configure a fluentd config file
|
|
|
|
# e.g. source, match etc.
|
|
|
|
#
|
|
|
|
define fluentd::config::file (
|
|
|
|
$ensure = present,
|
|
|
|
$priority = 50,
|
2015-12-01 13:18:06 +00:00
|
|
|
$content = undef,
|
2015-12-01 12:28:51 +00:00
|
|
|
) {
|
|
|
|
|
2015-12-01 14:29:53 +00:00
|
|
|
if $caller_module_name != $module_name {
|
|
|
|
fail("Use of private fluentd::config::file by ${caller_module_name}")
|
|
|
|
}
|
|
|
|
|
2015-12-01 12:28:51 +00:00
|
|
|
$base_name = "${title}.conf"
|
|
|
|
$config_name = "${priority}-${base_name}"
|
2015-12-04 13:20:11 +00:00
|
|
|
$config_path = "${::fluentd::conf_dir}/${config_name}"
|
2015-12-01 12:28:51 +00:00
|
|
|
|
|
|
|
# clean up to ensure priority changes take effect
|
|
|
|
exec { "apply priority change for ${base_name}":
|
2015-12-04 13:20:11 +00:00
|
|
|
command => "rm ${::fluentd::conf_dir}/*-${base_name}",
|
2015-12-07 10:09:31 +00:00
|
|
|
onlyif => "ls ${::fluentd::conf_dir}/*-${base_name} | grep -v ${config_name}",
|
2015-12-01 12:28:51 +00:00
|
|
|
before => File[$config_path],
|
2015-12-04 11:30:30 +00:00
|
|
|
notify => Class['Fluentd::Service'],
|
2015-12-01 12:28:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
file { $config_path:
|
|
|
|
ensure => $ensure,
|
|
|
|
content => $content,
|
|
|
|
owner => 'td-agent',
|
|
|
|
group => 'td-agent',
|
|
|
|
mode => '0644',
|
2015-12-04 11:30:30 +00:00
|
|
|
notify => Class['Fluentd::Service'],
|
2015-12-01 12:28:51 +00:00
|
|
|
}
|
|
|
|
}
|