diff --git a/README.md b/README.md index 0ff6b72..8ceb763 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ * [Source](#source) * [Filter](#filter) * [Match](#match) + * [Plugin Installation](#plugin-installation) * [Requirements](#requirements) 1. [Limitations - OS compatibility, etc.](#limitations) 1. [Development - Guide for contributing to the module](#development) @@ -112,6 +113,24 @@ include '::fluentd' ``` +### Plugin Installation + +This module gives you the possibility to install plugins as gem or files. + +**gem installation** +```puppet +::fluentd::plugin { 'fluent-plugin-elasticsearch': + type => 'gem' +} +``` +**file installation** +```puppet +::fluentd::plugin { 'fluent-plugin-elasticsearch': + type => 'file', + source => 'puppet:///path/to/plugin' +} +``` + ### Requirements Modules: diff --git a/manifests/plugin.pp b/manifests/plugin.pp new file mode 100644 index 0000000..9c1d7af --- /dev/null +++ b/manifests/plugin.pp @@ -0,0 +1,33 @@ +# Install fluentd plugins +# +define fluentd::plugin ( + $ensure = present, + $type = 'gem', + $source = undef, +) { + + # parameter validation + if ! ($ensure in [ 'present', 'absent' ]) { + fail('ensure parameter must be present or absent') + } + + case $type { + 'gem': { + fluentd::plugin::gem { $name: + ensure => $ensure, + require => Class['Fluentd::Install'] + } + } + 'file': { + validate_string($source) + + fluentd::plugin::file { $name: + ensure => $ensure, + require => Class['Fluentd::Install'] + } + } + default: { + fail("plugin type: '${type}' is currently not supported, use gem or file") + } + } +} diff --git a/manifests/plugin/file.pp b/manifests/plugin/file.pp new file mode 100644 index 0000000..ba4af6a --- /dev/null +++ b/manifests/plugin/file.pp @@ -0,0 +1,20 @@ +# Install fluentd file plugins +# +define fluentd::plugin::file ( + $ensure = present, + $source = undef, +) { + + if $caller_module_name != $module_name { + fail("Use of private fluentd::plugin::file by ${caller_module_name}") + } + + file { "/etc/td-agent/plugin/${name}": + ensure => $ensure, + owner => 'td-agent', + group => 'td-agent', + mode => '0640', + source => $source, + notify => Class['Fluentd::Service']; + } +} diff --git a/manifests/plugin/gem.pp b/manifests/plugin/gem.pp new file mode 100644 index 0000000..07c4df9 --- /dev/null +++ b/manifests/plugin/gem.pp @@ -0,0 +1,16 @@ +# Install fluentd gem plugins +# +define fluentd::plugin::gem ( + $ensure = present, +) { + + if $caller_module_name != $module_name { + fail("Use of private fluentd::plugin::gem by ${caller_module_name}") + } + + package { $name: + ensure => $ensure, + provider => 'fluentd_gem', + notify => Class['Fluentd::Service']; + } +}