mirror of
https://github.com/krislamo/puppet-fluentd
synced 2024-12-16 05:10:36 +00:00
added ::fluentd::user
this will manage the user if is set to true. This will add the td-agent user to the user group 'adm', so td-agent can view log files under /var/log/*.
This commit is contained in:
parent
6a08c099c4
commit
7821317f84
@ -27,7 +27,19 @@
|
||||
# Service ensure
|
||||
# Default: 'running'
|
||||
# [*service_enabled*]
|
||||
# Defines if the service should be enabled, defaults to 'true'
|
||||
# Defines if the service should be enabled
|
||||
# Default: 'true'
|
||||
# [*user_manage*]
|
||||
# Defines if the user should be manage, which will add the user
|
||||
# to groups defined in $user_groups.
|
||||
# For example to be able to view the /var/log directory with group adm
|
||||
# Default: 'true'
|
||||
# [*user_name*]
|
||||
# Default: 'td-agent'
|
||||
# [*user_group*]
|
||||
# Default: 'td-agent'
|
||||
# [*user_groups*]
|
||||
# Default: '["adm"]'
|
||||
#
|
||||
# Examples
|
||||
# --------
|
||||
@ -52,8 +64,10 @@ class fluentd (
|
||||
$config_path = $::fluentd::params::config_path,
|
||||
$conf_dir = $::fluentd::params::conf_dir,
|
||||
$config_file = $::fluentd::params::config_file,
|
||||
$user_manage = $::fluentd::params::user_manage,
|
||||
$user_name = $::fluentd::params::user_name,
|
||||
$user_group = $::fluentd::params::user_group,
|
||||
$user_groups = $::fluentd::params::user_groups,
|
||||
) inherits fluentd::params {
|
||||
|
||||
# parameter validation
|
||||
@ -72,12 +86,14 @@ class fluentd (
|
||||
# class calls
|
||||
include '::fluentd::repo'
|
||||
include '::fluentd::install'
|
||||
include '::fluentd::user'
|
||||
include '::fluentd::config'
|
||||
include '::fluentd::service'
|
||||
|
||||
# dependencies
|
||||
Class['::Fluentd::Repo'] ->
|
||||
Class['::Fluentd::Install'] ->
|
||||
Class['::Fluentd::User'] ->
|
||||
Class['::Fluentd::Config'] ->
|
||||
Class['::Fluentd::Service']
|
||||
}
|
||||
|
@ -13,8 +13,10 @@ class fluentd::params {
|
||||
$conf_dir = "${config_path}/conf.d"
|
||||
$config_file = "${config_path}/td-agent.conf"
|
||||
# user params
|
||||
$user_name = 'td-agent'
|
||||
$user_group = 'td-agent'
|
||||
$user_manage = true
|
||||
$user_name = 'td-agent'
|
||||
$user_group = 'td-agent'
|
||||
$user_groups = ['adm']
|
||||
|
||||
case $::osfamily {
|
||||
'Debian': {
|
||||
|
13
manifests/user.pp
Normal file
13
manifests/user.pp
Normal file
@ -0,0 +1,13 @@
|
||||
# Configure package
|
||||
#
|
||||
class fluentd::user inherits fluentd {
|
||||
|
||||
if $::fluentd::user_manage {
|
||||
user { 'fluentd':
|
||||
name => $::fluentd::user_name,
|
||||
gid => $::fluentd::user_group,
|
||||
groups => $::fluentd::user_groups,
|
||||
require => Class['Fluentd::Install'],
|
||||
}
|
||||
}
|
||||
}
|
22
spec/classes/fluentd_user_spec.rb
Normal file
22
spec/classes/fluentd_user_spec.rb
Normal file
@ -0,0 +1,22 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'fluentd::user', :type => :class do
|
||||
let(:facts) {
|
||||
{
|
||||
:osfamily => 'Debian',
|
||||
:lsbdistid => 'Ubuntu',
|
||||
:operatingsystem => 'Ubuntu',
|
||||
:lsbdistcodename => 'precise',
|
||||
}
|
||||
}
|
||||
|
||||
describe 'when called with no parameters on Ubuntu' do
|
||||
it {
|
||||
should contain_user('fluentd').with({
|
||||
'name' => 'td-agent',
|
||||
'gid' => 'td-agent',
|
||||
'groups' => ['adm']
|
||||
})
|
||||
}
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user