From 9d2175411bd9ab7189d9222ff0e8fa9dd30b30ed Mon Sep 17 00:00:00 2001 From: Max Wilhelm Date: Fri, 4 Dec 2015 14:20:11 +0100 Subject: [PATCH] parameterized config path, dir, file and user/group --- manifests/config.pp | 8 ++++---- manifests/config/file.pp | 7 +++---- manifests/init.pp | 5 +++++ manifests/params.pp | 7 +++++++ manifests/plugin/file.pp | 6 +++--- 5 files changed, 22 insertions(+), 11 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index 1b707b9..b2176be 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -2,7 +2,7 @@ # class fluentd::config inherits fluentd { - file { '/etc/td-agent/td-agent.conf' : + file { $config_file: ensure => file, owner => 'root', group => 'root', @@ -10,10 +10,10 @@ class fluentd::config inherits fluentd { notify => Class['Fluentd::Service'], } - file {'/etc/td-agent/conf.d': + file { $conf_dir: ensure => 'directory', - owner => 'td-agent', - group => 'td-agent', + owner => $user_name, + group => $user_group, mode => '0750', } diff --git a/manifests/config/file.pp b/manifests/config/file.pp index c1293fd..b7d05ad 100644 --- a/manifests/config/file.pp +++ b/manifests/config/file.pp @@ -13,13 +13,12 @@ define fluentd::config::file ( $base_name = "${title}.conf" $config_name = "${priority}-${base_name}" - $base_path = "/etc/td-agent/conf.d" - $config_path = "${base_path}/${config_name}" + $config_path = "${::fluentd::conf_dir}/${config_name}" # clean up to ensure priority changes take effect exec { "apply priority change for ${base_name}": - command => "rm ${base_path}/*-${base_name}", - onlyif => "ls ${base_path}/*-${base_name} | grep -v ${config_name}", + command => "rm ${::fluentd::conf_dir}/*-${base_name}", + onlyif => "ls ${::fluentd::conf_dir}/*-${base_name} | grep -v ${config_name}", before => File[$config_path], notify => Class['Fluentd::Service'], } diff --git a/manifests/init.pp b/manifests/init.pp index d6ef544..87a7684 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -49,6 +49,11 @@ class fluentd ( $service_name = $::fluentd::params::service_name, $service_ensure = $::fluentd::params::service_ensure, $service_enable = $::fluentd::params::service_enable, + $config_path = $::fluentd::params::config_path, + $conf_dir = $::fluentd::params::conf_dir, + $config_file = $::fluentd::params::config_file, + $user_name = $::fluentd::params::user_name, + $user_group = $::fluentd::params::user_group, ) inherits fluentd::params { # parameter validation diff --git a/manifests/params.pp b/manifests/params.pp index 325e478..f4075f4 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -8,6 +8,13 @@ class fluentd::params { $service_name = 'td-agent' $service_ensure = 'running' $service_enable = true + # config params + $config_path = '/etc/td-agent' + $conf_dir = "${config_path}/conf.d" + $config_file = "${config_path}/td-agent.conf" + # user params + $user_name = 'td-agent' + $user_group = 'td-agent' case $::osfamily { 'Debian': { diff --git a/manifests/plugin/file.pp b/manifests/plugin/file.pp index 966b9c8..81ce68e 100644 --- a/manifests/plugin/file.pp +++ b/manifests/plugin/file.pp @@ -9,10 +9,10 @@ define fluentd::plugin::file ( fail("Use of private fluentd::plugin::file by ${caller_module_name}") } - file { "/etc/td-agent/plugin/${name}": + file { "${::fluentd::config_path}/plugin/${name}": ensure => $ensure, - owner => 'td-agent', - group => 'td-agent', + owner => $::fluentd::user_name, + group => $::fluentd::user_group, mode => '0640', source => $source, notify => Class['Fluentd::Service']