mirror of
https://github.com/krislamo/puppet-fluentd
synced 2025-09-13 08:59:29 +00:00
Compare commits
42 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
540ef4e40d | ||
|
d92ea1e849 | ||
|
59fb7919a2 | ||
|
29122932ef | ||
|
72e6bcd744 | ||
|
3c537f0ff5 | ||
|
1077f6d5dd | ||
|
90a16243a6 | ||
|
dec8216a78 | ||
|
948431f50c | ||
|
d1d22c8874 | ||
|
0023cc7902 | ||
|
9eea9f2009 | ||
|
344453c241 | ||
|
71352ea6b1 | ||
|
d7ab62a388 | ||
|
78f9c03952 | ||
|
ca55558b44 | ||
|
cd9813f574 | ||
|
d6231c3b13 | ||
|
fc0f3fdf88 | ||
|
613a28ccaf | ||
|
5f213da8b3 | ||
|
258a37ff11 | ||
|
c2f95f4bc9 | ||
|
257880811c | ||
|
6e97016aac | ||
|
b34c7dc4e4 | ||
|
d7f6d91a11 | ||
|
e8cdc9a9e0 | ||
|
b51a559684 | ||
|
754cd4a696 | ||
|
41a617c156 | ||
|
0c62c616f0 | ||
|
76d26e8216 | ||
|
780df1edae | ||
|
3e3de2aed9 | ||
|
5f84f04f0f | ||
|
ad17694713 | ||
|
f4da637999 | ||
|
533857e49c | ||
|
525fc9c5ab |
@@ -6,8 +6,6 @@ script: bundle exec rake validate && bundle exec rake lint && bundle exec rake s
|
|||||||
matrix:
|
matrix:
|
||||||
fast_finish: true
|
fast_finish: true
|
||||||
include:
|
include:
|
||||||
- rvm: 2.1.10
|
|
||||||
env: PUPPET_VERSION="~> 3.0"
|
|
||||||
- rvm: 2.1.10
|
- rvm: 2.1.10
|
||||||
env: PUPPET_VERSION="~> 4.0" STRICT_VARIABLES="yes"
|
env: PUPPET_VERSION="~> 4.0" STRICT_VARIABLES="yes"
|
||||||
- rvm: 2.2.7
|
- rvm: 2.2.7
|
||||||
|
14
CHANGELOG.md
14
CHANGELOG.md
@@ -1,4 +1,18 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 1.0.0
|
||||||
|
|
||||||
|
**Breaking changes:** This version drops puppet 3 support!
|
||||||
|
|
||||||
|
* Fix hard coded user/group names in config manifest (#23)
|
||||||
|
* migrate from stdlib validation to puppet datatypes (#24)
|
||||||
|
|
||||||
|
## 0.6.0
|
||||||
|
* Updated README
|
||||||
|
* fixed broken links, due to github organisation rename
|
||||||
|
* fixed indentation for config files (filter, match, source)
|
||||||
|
* use rspec-puppet-facts for unit testing
|
||||||
|
|
||||||
## 0.5.6
|
## 0.5.6
|
||||||
* Fixed `conf_dir_manage` parameter call
|
* Fixed `conf_dir_manage` parameter call
|
||||||
|
|
||||||
|
7
Gemfile
7
Gemfile
@@ -1,12 +1,13 @@
|
|||||||
source 'https://rubygems.org'
|
source 'https://rubygems.org'
|
||||||
|
|
||||||
ENV['PUPPET_VERSION'].nil? ? puppetversion = '~> 4.0' : puppetversion = ENV['PUPPET_VERSION'].to_s
|
ENV['PUPPET_VERSION'].nil? ? puppetversion = '~> 4.6' : puppetversion = ENV['PUPPET_VERSION'].to_s
|
||||||
gem 'puppet', puppetversion
|
gem 'puppet', puppetversion
|
||||||
gem 'puppetlabs_spec_helper', '>= 0.8.2'
|
gem 'puppetlabs_spec_helper', '>= 0.8.2'
|
||||||
gem 'puppet-lint', '>= 1.0.0'
|
gem 'puppet-lint', '>= 1.0.0'
|
||||||
gem 'facter', '>= 1.7.0'
|
gem 'facter', '>= 1.7.0'
|
||||||
gem 'beaker-puppet_install_helper'
|
gem 'beaker-puppet_install_helper'
|
||||||
gem 'metadata-json-lint'
|
gem 'metadata-json-lint'
|
||||||
|
gem 'rspec-puppet-facts', '~> 1.7'
|
||||||
|
|
||||||
beakerrspec = '> 0'
|
beakerrspec = '> 0'
|
||||||
platforms [:ruby_19, :ruby_21] do
|
platforms [:ruby_19, :ruby_21] do
|
||||||
@@ -16,6 +17,6 @@ gem 'beaker-rspec', beakerrspec
|
|||||||
|
|
||||||
platforms :ruby_19 do
|
platforms :ruby_19 do
|
||||||
gem 'public_suffix', '< 1.5.0', :platforms => :ruby_19
|
gem 'public_suffix', '< 1.5.0', :platforms => :ruby_19
|
||||||
gem 'nokogiri', '< 1.7.0', :platforms => :ruby_19
|
gem 'nokogiri', '~> 1.8.1', :platforms => :ruby_19
|
||||||
gem 'mime-types', '< 3.0', :platforms => :ruby_19
|
gem 'mime-types', '< 3.0', :platforms => :ruby_19
|
||||||
end
|
end
|
||||||
|
2
LICENSE
2
LICENSE
@@ -186,7 +186,7 @@
|
|||||||
same "printed page" as the copyright notice for easier
|
same "printed page" as the copyright notice for easier
|
||||||
identification within third-party archives.
|
identification within third-party archives.
|
||||||
|
|
||||||
Copyright 2015 wywy GmbH
|
Copyright 2017 ATVAG GmbH
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
74
README.md
74
README.md
@@ -1,7 +1,7 @@
|
|||||||
# wywygmbh/fluentd Puppet Module
|
# pilchkinstein-gtv/fluentd Puppet Module
|
||||||
|
|
||||||
[](https://github.com/wywygmbh/puppet-fluentd)
|
[](https://github.com/pilchkinstein-gtv/puppet-fluentd)
|
||||||
[](https://travis-ci.org/wywygmbh/puppet-fluentd)
|
[](https://travis-ci.org/wywy/puppet-fluentd)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -48,42 +48,62 @@ include '::fluentd'
|
|||||||
|
|
||||||
Include repository to install recent fluentd (td-agent) from.
|
Include repository to install recent fluentd (td-agent) from.
|
||||||
**Default:** 'true'
|
**Default:** 'true'
|
||||||
|
|
||||||
`package_ensure`
|
`package_ensure`
|
||||||
|
|
||||||
Package ensure.
|
Package ensure.
|
||||||
**Default:** 'installed'
|
**Default:** 'installed'
|
||||||
|
|
||||||
`package_name`
|
`package_name`
|
||||||
|
|
||||||
Package name.
|
Package name.
|
||||||
**Default:** 'td-agent'
|
**Default:** 'td-agent'
|
||||||
|
|
||||||
`package_install_options`
|
`package_install_options`
|
||||||
|
|
||||||
Package install options.
|
Package install options.
|
||||||
**Default:** '[]'
|
**Default:** '[]'
|
||||||
|
|
||||||
`service_manage`
|
`service_manage`
|
||||||
|
|
||||||
Defines if the service should be managed by puppet.
|
Defines if the service should be managed by puppet.
|
||||||
**Default:** 'true'
|
**Default:** 'true'
|
||||||
|
|
||||||
`service_name`
|
`service_name`
|
||||||
|
|
||||||
Name of the service.
|
Name of the service.
|
||||||
**Default:** 'td-agent'
|
**Default:** 'td-agent'
|
||||||
|
|
||||||
`service_ensure`
|
`service_ensure`
|
||||||
|
|
||||||
Service ensure.
|
Service ensure.
|
||||||
**Default:** 'running'
|
**Default:** 'running'
|
||||||
|
|
||||||
`service_enable`
|
`service_enable`
|
||||||
|
|
||||||
Defines if the service should be enabled.
|
Defines if the service should be enabled.
|
||||||
**Default:** 'true'
|
**Default:** 'true'
|
||||||
|
|
||||||
|
`config_path`
|
||||||
|
|
||||||
|
Path to configuration files
|
||||||
|
**Default:** '/etc/td-agent'
|
||||||
|
|
||||||
|
`config_dir`
|
||||||
|
|
||||||
|
Configuration directory name
|
||||||
|
**Default:** '${config_path}/conf.d'
|
||||||
|
|
||||||
|
`config_file`
|
||||||
|
|
||||||
|
Default configuration file name
|
||||||
|
**Default:** '${config_path}/td-agent.conf'
|
||||||
|
|
||||||
|
`conf_dir_manage`
|
||||||
|
|
||||||
|
Exclusively handle config files into fluentd::conf_dir. Other files not created by puppet, will be deleted
|
||||||
|
**Default:** 'false'
|
||||||
|
|
||||||
`user_manage`
|
`user_manage`
|
||||||
|
|
||||||
Defines if the user should be manage, which will add the user
|
Defines if the user should be manage, which will add the user
|
||||||
@@ -94,11 +114,11 @@ include '::fluentd'
|
|||||||
`user_name`
|
`user_name`
|
||||||
|
|
||||||
**Default:** 'td-agent'
|
**Default:** 'td-agent'
|
||||||
|
|
||||||
`user_group`
|
`user_group`
|
||||||
|
|
||||||
**Default:** 'td-agent'
|
**Default:** 'td-agent'
|
||||||
|
|
||||||
`user_groups`
|
`user_groups`
|
||||||
|
|
||||||
**Default:** '["adm"]'
|
**Default:** '["adm"]'
|
||||||
@@ -111,6 +131,14 @@ include '::fluentd'
|
|||||||
'type' => 'tail',
|
'type' => 'tail',
|
||||||
'format' => 'json',
|
'format' => 'json',
|
||||||
'path' => '/var/log/test-application/*.json',
|
'path' => '/var/log/test-application/*.json',
|
||||||
|
'parse' => {
|
||||||
|
'type' => 'regexp',
|
||||||
|
'expression' => '^(?<name>[^ ]*) (?<user>[^ ]*) (?<age>\d*)$'
|
||||||
|
},
|
||||||
|
'storage'=> {
|
||||||
|
'type' => 'local',
|
||||||
|
'path' => 'test.pos'
|
||||||
|
},
|
||||||
'tag' => 'application.test'
|
'tag' => 'application.test'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -122,6 +150,14 @@ include '::fluentd'
|
|||||||
type tail
|
type tail
|
||||||
format json
|
format json
|
||||||
path /var/log/test-application/*.json
|
path /var/log/test-application/*.json
|
||||||
|
<parse>
|
||||||
|
type regexp
|
||||||
|
expression ^(?<name>[^ ]*) (?<user>[^ ]*) (?<age>\d*)$
|
||||||
|
</parse>
|
||||||
|
<storage>
|
||||||
|
type local
|
||||||
|
path test.pos
|
||||||
|
</storage>
|
||||||
tag application.test
|
tag application.test
|
||||||
</source>
|
</source>
|
||||||
```
|
```
|
||||||
@@ -243,14 +279,14 @@ This module gives you the possibility to install plugins as gem or files.
|
|||||||
### Requirements
|
### Requirements
|
||||||
|
|
||||||
Modules:
|
Modules:
|
||||||
* puppetlabs/apt >= 1.8.0 < 3.0.0
|
* puppetlabs/apt >= 4.0.0
|
||||||
|
|
||||||
## Limitations
|
## Limitations
|
||||||
This module has been built on and tested against Puppet 3.7.5 and higher.
|
This module has been built on and tested against Puppet 4.6 and higher.
|
||||||
|
|
||||||
The module has been tested on:
|
The module has been tested on:
|
||||||
|
|
||||||
* Ubuntu 12.04
|
* Ubuntu 16.04
|
||||||
|
|
||||||
Testing on other platforms has been light and cannot be guaranteed.
|
Testing on other platforms has been light and cannot be guaranteed.
|
||||||
|
|
||||||
@@ -265,8 +301,8 @@ To run the tests install the ruby dependencies with `bundler` and execute
|
|||||||
bundle install --path vendor/bundle
|
bundle install --path vendor/bundle
|
||||||
bundle exec rake spec
|
bundle exec rake spec
|
||||||
bundle exec rake lint
|
bundle exec rake lint
|
||||||
bundle exec rake beaker BEAKER_set=ubuntu-server-1204-x64
|
|
||||||
bundle exec rake beaker BEAKER_set=ubuntu-server-1404-x64
|
bundle exec rake beaker BEAKER_set=ubuntu-server-1404-x64
|
||||||
|
bundle exec rake beaker BEAKER_set=ubuntu-server-1604-x64
|
||||||
bundle exec rake beaker BEAKER_set=debian-60-x64
|
bundle exec rake beaker BEAKER_set=debian-60-x64
|
||||||
bundle exec rake beaker BEAKER_set=debian-78-x64
|
bundle exec rake beaker BEAKER_set=debian-78-x64
|
||||||
bundle exec rake beaker BEAKER_set=debian-82-x64
|
bundle exec rake beaker BEAKER_set=debian-82-x64
|
||||||
@@ -276,7 +312,7 @@ bundle exec rake beaker BEAKER_set=centos-70-x64
|
|||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Copyright 2015 wywy GmbH
|
Copyright 2017 ATVAG GmbH
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -290,4 +326,4 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
|
|
||||||
This Puppet module is being actively maintained by some fellow puppeteers at [wywy GmbH](http://wywy.com/).
|
This Puppet module is being actively maintained by some fellow puppeteers at [wywy](http://wywy.com/).
|
||||||
|
3
Rakefile
3
Rakefile
@@ -4,8 +4,9 @@ require 'puppet-lint/tasks/puppet-lint'
|
|||||||
PuppetLint.configuration.log_format = '%{path}:%{line}:%{check}:%{KIND}:%{message}'
|
PuppetLint.configuration.log_format = '%{path}:%{line}:%{check}:%{KIND}:%{message}'
|
||||||
PuppetLint.configuration.fail_on_warnings = true
|
PuppetLint.configuration.fail_on_warnings = true
|
||||||
PuppetLint.configuration.send('relative')
|
PuppetLint.configuration.send('relative')
|
||||||
PuppetLint.configuration.send('disable_140chars')
|
PuppetLint.configuration.send('disable_80chars')
|
||||||
PuppetLint.configuration.send('disable_class_inherits_from_params_class')
|
PuppetLint.configuration.send('disable_class_inherits_from_params_class')
|
||||||
|
PuppetLint.configuration.send('disable_class_parameter_defaults')
|
||||||
PuppetLint.configuration.send('disable_documentation')
|
PuppetLint.configuration.send('disable_documentation')
|
||||||
PuppetLint.configuration.send('disable_single_quote_string_with_variables')
|
PuppetLint.configuration.send('disable_single_quote_string_with_variables')
|
||||||
|
|
||||||
|
@@ -2,9 +2,17 @@
|
|||||||
::fluentd::source { 'test':
|
::fluentd::source { 'test':
|
||||||
priority => 10,
|
priority => 10,
|
||||||
config => {
|
config => {
|
||||||
'type' => 'tail',
|
'type' => 'tail',
|
||||||
'format' => 'json',
|
'format' => 'json',
|
||||||
'path' => '/var/log/test-application/*.json',
|
'path' => '/var/log/test-application/*.json',
|
||||||
'tag' => 'application.test'
|
'parse' => {
|
||||||
|
'type' => 'regexp',
|
||||||
|
'expression' => '^(?<name>[^ ]*) (?<user>[^ ]*) (?<age>\d*)$'
|
||||||
|
},
|
||||||
|
'storage' => {
|
||||||
|
'type' => 'local',
|
||||||
|
'path' => 'test.pos'
|
||||||
|
},
|
||||||
|
'tag' => 'application.test'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -28,8 +28,8 @@ define fluentd::config::file (
|
|||||||
file { $config_path:
|
file { $config_path:
|
||||||
ensure => $ensure,
|
ensure => $ensure,
|
||||||
content => $content,
|
content => $content,
|
||||||
owner => 'td-agent',
|
owner => $::fluentd::user_name,
|
||||||
group => 'td-agent',
|
group => $::fluentd::user_group,
|
||||||
mode => '0644',
|
mode => '0644',
|
||||||
notify => Class['Fluentd::Service'],
|
notify => Class['Fluentd::Service'],
|
||||||
}
|
}
|
||||||
|
@@ -35,26 +35,19 @@
|
|||||||
# Copyright
|
# Copyright
|
||||||
# ---------
|
# ---------
|
||||||
#
|
#
|
||||||
# Copyright 2015 wywy GmbH, unless otherwise noted.
|
# Copyright 2015 wywy, unless otherwise noted.
|
||||||
#
|
#
|
||||||
define fluentd::filter (
|
define fluentd::filter (
|
||||||
$ensure = present,
|
Enum['present', 'absent'] $ensure = present,
|
||||||
$priority = 20,
|
Integer $priority = 20,
|
||||||
$pattern = '**',
|
String $pattern = '**',
|
||||||
$config = {},
|
Hash $config = {},
|
||||||
) {
|
) {
|
||||||
|
|
||||||
# parameter validation
|
|
||||||
if ! ($ensure in [ 'present', 'absent' ]) {
|
|
||||||
fail('ensure parameter must be present or absent')
|
|
||||||
}
|
|
||||||
validate_integer($priority)
|
|
||||||
validate_string($pattern)
|
|
||||||
validate_hash($config)
|
|
||||||
|
|
||||||
fluentd::config::file { "filter-${title}":
|
fluentd::config::file { "filter-${title}":
|
||||||
ensure => $ensure,
|
ensure => $ensure,
|
||||||
priority => $priority,
|
priority => $priority,
|
||||||
content => template( 'fluentd/filter.erb'),
|
content => template( 'fluentd/filter.erb'),
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -8,9 +8,6 @@
|
|||||||
# [*repo_manage*]
|
# [*repo_manage*]
|
||||||
# Include repository to install recent fluentd (td-agent) from
|
# Include repository to install recent fluentd (td-agent) from
|
||||||
# Default: 'true'
|
# Default: 'true'
|
||||||
# [*conf_dir_manage*]
|
|
||||||
# Exclusively handle config files into fluentd::conf_dir. Other files not created by puppet, will be deleted
|
|
||||||
# Default: 'false'
|
|
||||||
# [*package_ensure*]
|
# [*package_ensure*]
|
||||||
# Package ensure
|
# Package ensure
|
||||||
# Default: 'installed'
|
# Default: 'installed'
|
||||||
@@ -32,6 +29,18 @@
|
|||||||
# [*service_enable*]
|
# [*service_enable*]
|
||||||
# Defines if the service should be enabled
|
# Defines if the service should be enabled
|
||||||
# Default: 'true'
|
# Default: 'true'
|
||||||
|
# [*config_path*]
|
||||||
|
# Path to configuration files
|
||||||
|
# Default: '/etc/td-agent'
|
||||||
|
# [*config_dir*]
|
||||||
|
# Configuration directory name
|
||||||
|
# Default: '${config_path}/conf.d'
|
||||||
|
# [*config_file*]
|
||||||
|
# Default configuration file name
|
||||||
|
# Default: '${config_path}/td-agent.conf'
|
||||||
|
# [*conf_dir_manage*]
|
||||||
|
# Exclusively handle config files into fluentd::conf_dir. Other files not created by puppet, will be deleted
|
||||||
|
# Default: 'false'
|
||||||
# [*user_manage*]
|
# [*user_manage*]
|
||||||
# Defines if the user should be manage, which will add the user
|
# Defines if the user should be manage, which will add the user
|
||||||
# to groups defined in $user_groups.
|
# to groups defined in $user_groups.
|
||||||
@@ -53,40 +62,27 @@
|
|||||||
# Copyright
|
# Copyright
|
||||||
# ---------
|
# ---------
|
||||||
#
|
#
|
||||||
# Copyright 2015 wywy GmbH, unless otherwise noted.
|
# Copyright 2015 wywy, unless otherwise noted.
|
||||||
#
|
#
|
||||||
class fluentd (
|
class fluentd (
|
||||||
$repo_manage = $::fluentd::params::repo_manage,
|
Boolean $repo_manage = $::fluentd::params::repo_manage,
|
||||||
$package_ensure = $::fluentd::params::package_ensure,
|
String $package_ensure = $::fluentd::params::package_ensure,
|
||||||
$package_name = $::fluentd::params::package_name,
|
String $package_name = $::fluentd::params::package_name,
|
||||||
$package_install_options = $::fluentd::params::package_install_options,
|
Array $package_install_options = $::fluentd::params::package_install_options,
|
||||||
$service_manage = $::fluentd::params::service_manage,
|
Boolean $service_manage = $::fluentd::params::service_manage,
|
||||||
$service_name = $::fluentd::params::service_name,
|
String $service_name = $::fluentd::params::service_name,
|
||||||
$service_ensure = $::fluentd::params::service_ensure,
|
Enum['running', 'stopped'] $service_ensure = $::fluentd::params::service_ensure,
|
||||||
$service_enable = $::fluentd::params::service_enable,
|
Boolean $service_enable = $::fluentd::params::service_enable,
|
||||||
$config_path = $::fluentd::params::config_path,
|
String $config_path = $::fluentd::params::config_path,
|
||||||
$conf_dir = $::fluentd::params::conf_dir,
|
String $conf_dir = $::fluentd::params::conf_dir,
|
||||||
$conf_dir_manage = $::fluentd::params::conf_dir_manage,
|
String $config_file = $::fluentd::params::config_file,
|
||||||
$config_file = $::fluentd::params::config_file,
|
Boolean $conf_dir_manage = $::fluentd::params::conf_dir_manage,
|
||||||
$user_manage = $::fluentd::params::user_manage,
|
Boolean $user_manage = $::fluentd::params::user_manage,
|
||||||
$user_name = $::fluentd::params::user_name,
|
String $user_name = $::fluentd::params::user_name,
|
||||||
$user_group = $::fluentd::params::user_group,
|
String $user_group = $::fluentd::params::user_group,
|
||||||
$user_groups = $::fluentd::params::user_groups,
|
Array $user_groups = $::fluentd::params::user_groups,
|
||||||
) inherits fluentd::params {
|
) inherits fluentd::params {
|
||||||
|
|
||||||
# parameter validation
|
|
||||||
validate_bool($repo_manage)
|
|
||||||
validate_string($package_ensure)
|
|
||||||
validate_string($package_name)
|
|
||||||
validate_array($package_install_options)
|
|
||||||
validate_bool($service_manage)
|
|
||||||
validate_string($service_name)
|
|
||||||
validate_bool($service_enable)
|
|
||||||
|
|
||||||
if ! ($service_ensure in [ 'running', 'stopped' ]) {
|
|
||||||
fail('service_ensure parameter must be running or stopped')
|
|
||||||
}
|
|
||||||
|
|
||||||
# class calls
|
# class calls
|
||||||
include '::fluentd::repo'
|
include '::fluentd::repo'
|
||||||
include '::fluentd::install'
|
include '::fluentd::install'
|
||||||
|
@@ -40,26 +40,19 @@
|
|||||||
# Copyright
|
# Copyright
|
||||||
# ---------
|
# ---------
|
||||||
#
|
#
|
||||||
# Copyright 2015 wywy GmbH, unless otherwise noted.
|
# Copyright 2015 wywy, unless otherwise noted.
|
||||||
#
|
#
|
||||||
define fluentd::match (
|
define fluentd::match (
|
||||||
$ensure = present,
|
Enum['present', 'absent'] $ensure = present,
|
||||||
$priority = 30,
|
Integer $priority = 30,
|
||||||
$pattern = '**',
|
String $pattern = '**',
|
||||||
$config = {},
|
Hash $config = {},
|
||||||
) {
|
) {
|
||||||
|
|
||||||
# parameter validation
|
|
||||||
if ! ($ensure in [ 'present', 'absent' ]) {
|
|
||||||
fail('ensure parameter must be present or absent')
|
|
||||||
}
|
|
||||||
validate_integer($priority)
|
|
||||||
validate_string($pattern)
|
|
||||||
validate_hash($config)
|
|
||||||
|
|
||||||
fluentd::config::file { "match-${title}":
|
fluentd::config::file { "match-${title}":
|
||||||
ensure => $ensure,
|
ensure => $ensure,
|
||||||
priority => $priority,
|
priority => $priority,
|
||||||
content => template( 'fluentd/match.erb'),
|
content => template( 'fluentd/match.erb'),
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -23,12 +23,12 @@
|
|||||||
# Copyright
|
# Copyright
|
||||||
# ---------
|
# ---------
|
||||||
#
|
#
|
||||||
# Copyright 2015 wywy GmbH, unless otherwise noted.
|
# Copyright 2015 wywy, unless otherwise noted.
|
||||||
#
|
#
|
||||||
define fluentd::plugin (
|
define fluentd::plugin (
|
||||||
$ensure = present,
|
String $ensure = present,
|
||||||
$type = 'gem',
|
String $type = 'gem',
|
||||||
$source = undef,
|
Optional[String] $source = undef,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
case $type {
|
case $type {
|
||||||
@@ -43,7 +43,6 @@ define fluentd::plugin (
|
|||||||
if ! ($ensure in [ 'present', 'absent' ]) {
|
if ! ($ensure in [ 'present', 'absent' ]) {
|
||||||
fail('ensure parameter must be present or absent')
|
fail('ensure parameter must be present or absent')
|
||||||
}
|
}
|
||||||
validate_string($source)
|
|
||||||
|
|
||||||
fluentd::plugin::file { $name:
|
fluentd::plugin::file { $name:
|
||||||
ensure => $ensure,
|
ensure => $ensure,
|
||||||
|
@@ -31,20 +31,18 @@
|
|||||||
# Copyright
|
# Copyright
|
||||||
# ---------
|
# ---------
|
||||||
#
|
#
|
||||||
# Copyright 2015 wywy GmbH, unless otherwise noted.
|
# Copyright 2015 wywy, unless otherwise noted.
|
||||||
#
|
#
|
||||||
define fluentd::source (
|
define fluentd::source (
|
||||||
$ensure = present,
|
String $ensure = present,
|
||||||
$priority = 10,
|
Integer $priority = 10,
|
||||||
$config = {},
|
Hash $config = {},
|
||||||
) {
|
) {
|
||||||
|
|
||||||
# parameter validation
|
# parameter validation
|
||||||
if ! ($ensure in [ 'present', 'absent' ]) {
|
if ! ($ensure in [ 'present', 'absent' ]) {
|
||||||
fail('ensure parameter must be present or absent')
|
fail('ensure parameter must be present or absent')
|
||||||
}
|
}
|
||||||
validate_integer($priority)
|
|
||||||
validate_hash($config)
|
|
||||||
|
|
||||||
fluentd::config::file { "source-${title}":
|
fluentd::config::file { "source-${title}":
|
||||||
ensure => $ensure,
|
ensure => $ensure,
|
||||||
|
@@ -1,17 +1,17 @@
|
|||||||
{
|
{
|
||||||
"name": "wywygmbh-fluentd",
|
"name": "pilchkinstein-fluentd",
|
||||||
"version": "0.5.6",
|
"version": "1.0.0",
|
||||||
"author": "wywy GmbH",
|
"author": "pilchkinstein-gtv",
|
||||||
"summary": "Generic module for fluentd (td-agent).",
|
"summary": "Generic module for fluentd (td-agent).",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"source": "https://github.com/wywygmbh/puppet-fluentd",
|
"source": "https://github.com/pilchkinstein-gtv/puppet-fluentd",
|
||||||
"project_page": "https://github.com/wywygmbh/puppet-fluentd",
|
"project_page": "https://github.com/pilchkinstein-gtv/puppet-fluentd",
|
||||||
"issues_url": "https://github.com/wywygmbh/puppet-fluentd/issues",
|
"issues_url": "https://github.com/pilchkinstein-gtv/puppet-fluentd/issues",
|
||||||
"tags": ["fluentd", "td-agent"],
|
"tags": ["fluentd", "td-agent"],
|
||||||
"operatingsystem_support": [
|
"operatingsystem_support": [
|
||||||
{
|
{
|
||||||
"operatingsystem": "Ubuntu",
|
"operatingsystem": "Ubuntu",
|
||||||
"operatingsystemrelease": [ "14.04", "12.04" ]
|
"operatingsystemrelease": [ "16.04", "14.04" ]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"operatingsystem": "Debian",
|
"operatingsystem": "Debian",
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
],
|
],
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
{ "name": "puppetlabs/stdlib", "version_requirement": ">= 4.6.0 < 5.0.0" },
|
{ "name": "puppetlabs/stdlib", "version_requirement": ">= 4.6.0 < 5.0.0" },
|
||||||
{ "name": "puppetlabs/apt", "version_requirement": ">= 2.0.0 < 3.0.0" }
|
{ "name": "puppetlabs/apt", "version_requirement": ">= 4.0.0" }
|
||||||
],
|
],
|
||||||
"data_provider": null
|
"data_provider": null
|
||||||
}
|
}
|
||||||
|
@@ -1,46 +1,31 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe 'fluentd::config', :type => :class do
|
describe 'fluentd::config', :type => :class do
|
||||||
shared_examples 'when called with no parameters' do
|
on_supported_os.each do |os, facts|
|
||||||
it {
|
context "on #{os}" do
|
||||||
should contain_file('/etc/td-agent/td-agent.conf').with({
|
let :facts do
|
||||||
'ensure' => 'file',
|
facts
|
||||||
'owner' => 'root',
|
end
|
||||||
'group' => 'root',
|
|
||||||
'source' => 'puppet:///modules/fluentd/td-agent.conf',
|
|
||||||
'notify' => 'Class[Fluentd::Service]'
|
|
||||||
})
|
|
||||||
|
|
||||||
should contain_file('/etc/td-agent/conf.d').with({
|
describe 'when called with no parameters' do
|
||||||
'ensure' => 'directory',
|
|
||||||
'owner' => 'td-agent',
|
|
||||||
'group' => 'td-agent',
|
|
||||||
'mode' => '0750'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when osfamily is Debian' do
|
it {
|
||||||
let(:facts) {
|
should contain_file('/etc/td-agent/td-agent.conf').with({
|
||||||
{
|
'ensure' => 'file',
|
||||||
:osfamily => 'Debian',
|
'owner' => 'root',
|
||||||
:lsbdistid => 'Ubuntu',
|
'group' => 'root',
|
||||||
:operatingsystem => 'Ubuntu',
|
'source' => 'puppet:///modules/fluentd/td-agent.conf',
|
||||||
:lsbdistcodename => 'precise',
|
'notify' => 'Class[Fluentd::Service]'
|
||||||
:architecture => 'amd64',
|
})
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
include_examples 'when called with no parameters'
|
should contain_file('/etc/td-agent/conf.d').with({
|
||||||
end
|
'ensure' => 'directory',
|
||||||
|
'owner' => 'td-agent',
|
||||||
context 'when osfamily is RedHat' do
|
'group' => 'td-agent',
|
||||||
let(:facts) {
|
'mode' => '0750'
|
||||||
{
|
})
|
||||||
:osfamily => 'RedHat',
|
}
|
||||||
}
|
end
|
||||||
}
|
end
|
||||||
|
|
||||||
include_examples 'when called with no parameters'
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@@ -1,38 +1,21 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe 'fluentd::install', :type => :class do
|
describe 'fluentd::install', :type => :class do
|
||||||
|
on_supported_os.each do |os, facts|
|
||||||
|
context "on #{os}" do
|
||||||
|
let :facts do
|
||||||
|
facts
|
||||||
|
end
|
||||||
|
|
||||||
shared_examples 'when called with no parameters' do
|
describe 'when called with no parameters' do
|
||||||
it {
|
it {
|
||||||
should contain_package('fluentd').with({
|
should contain_package('fluentd').with({
|
||||||
'ensure' => 'installed',
|
'ensure' => 'installed',
|
||||||
'name' => 'td-agent',
|
'name' => 'td-agent',
|
||||||
'install_options' => []
|
'install_options' => []
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when osfamily is Debian' do
|
|
||||||
let(:facts) {
|
|
||||||
{
|
|
||||||
:osfamily => 'Debian',
|
|
||||||
:lsbdistid => 'Ubuntu',
|
|
||||||
:operatingsystem => 'Ubuntu',
|
|
||||||
:lsbdistcodename => 'precise',
|
|
||||||
:architecture => 'amd64',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
include_examples 'when called with no parameters'
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when osfamily is RedHat' do
|
|
||||||
let(:facts) {
|
|
||||||
{
|
|
||||||
:osfamily => 'RedHat',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
include_examples 'when called with no parameters'
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@@ -1,34 +1,81 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe 'fluentd::repo::apt', :type => :class do
|
describe 'fluentd::repo::apt', :type => :class do
|
||||||
let(:facts) {
|
on_supported_os.each do |os, facts|
|
||||||
{
|
context "on #{os}" do
|
||||||
:osfamily => 'Debian',
|
let :facts do
|
||||||
:lsbdistid => 'Ubuntu',
|
facts
|
||||||
:operatingsystem => 'Ubuntu',
|
end
|
||||||
:lsbdistcodename => 'precise',
|
|
||||||
:architecture => 'amd64',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
describe 'when called with no parameters on Ubuntu' do
|
case facts[:osfamily]
|
||||||
it {
|
when 'Debian'
|
||||||
should contain_class('apt')
|
it {
|
||||||
should contain_apt__source('treasure-data').with({
|
should contain_class('apt')
|
||||||
'ensure' => 'present',
|
should contain_apt__source('treasure-data').with({
|
||||||
'location' => 'http://packages.treasuredata.com/2/ubuntu/precise',
|
'ensure' => 'present',
|
||||||
'release' => 'precise',
|
'repos' => 'contrib',
|
||||||
'repos' => 'contrib',
|
'architecture' => 'amd64',
|
||||||
'architecture' => 'amd64',
|
'key' => {
|
||||||
'key' => {
|
'id' => 'BEE682289B2217F45AF4CC3F901F9177AB97ACBE',
|
||||||
'id' => 'BEE682289B2217F45AF4CC3F901F9177AB97ACBE',
|
'source' => 'http://packages.treasuredata.com/GPG-KEY-td-agent'
|
||||||
'source' => 'http://packages.treasuredata.com/GPG-KEY-td-agent'
|
},
|
||||||
},
|
'include' => {
|
||||||
'include' => {
|
'src' => false,
|
||||||
'src' => false,
|
'deb' => true
|
||||||
'deb' => true
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
case facts[:operatingsystem]
|
||||||
}
|
when 'Ubuntu'
|
||||||
|
case facts[:lsbdistcodename]
|
||||||
|
when 'precise'
|
||||||
|
it {
|
||||||
|
should contain_apt__source('treasure-data').with({
|
||||||
|
'location' => 'http://packages.treasuredata.com/2/ubuntu/precise',
|
||||||
|
'release' => 'precise'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
when 'trusty'
|
||||||
|
it {
|
||||||
|
should contain_apt__source('treasure-data').with({
|
||||||
|
'location' => 'http://packages.treasuredata.com/2/ubuntu/trusty',
|
||||||
|
'release' => 'trusty'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
when 'xenial'
|
||||||
|
it {
|
||||||
|
should contain_apt__source('treasure-data').with({
|
||||||
|
'location' => 'http://packages.treasuredata.com/2/ubuntu/xenial',
|
||||||
|
'release' => 'xenial'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
end
|
||||||
|
when 'Debian'
|
||||||
|
case facts[:lsbdistcodename]
|
||||||
|
when 'jessie'
|
||||||
|
it {
|
||||||
|
should contain_apt__source('treasure-data').with({
|
||||||
|
'location' => 'http://packages.treasuredata.com/2/debian/jessie',
|
||||||
|
'release' => 'jessie'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
when 'squeeze'
|
||||||
|
it {
|
||||||
|
should contain_apt__source('treasure-data').with({
|
||||||
|
'location' => 'http://packages.treasuredata.com/2/debian/squeeze',
|
||||||
|
'release' => 'squeeze'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
when 'wheezy'
|
||||||
|
it {
|
||||||
|
should contain_apt__source('treasure-data').with({
|
||||||
|
'location' => 'http://packages.treasuredata.com/2/debian/wheezy',
|
||||||
|
'release' => 'wheezy'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@@ -1,30 +1,21 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe 'fluentd::repo', :type => :class do
|
describe 'fluentd::repo', :type => :class do
|
||||||
|
on_supported_os.each do |os, facts|
|
||||||
|
context "on #{os}" do
|
||||||
|
let :facts do
|
||||||
|
facts
|
||||||
|
end
|
||||||
|
|
||||||
context 'when called with no parameters on osfamily Debian' do
|
describe 'when called with no parameters' do
|
||||||
let(:facts) {
|
case facts[:osfamily]
|
||||||
{
|
when 'Debian'
|
||||||
:osfamily => 'Debian',
|
it { is_expected.to contain_class('fluentd::repo::apt') }
|
||||||
:lsbdistid => 'Ubuntu',
|
when 'RedHat'
|
||||||
:operatingsystem => 'Ubuntu',
|
it { is_expected.to contain_class('fluentd::repo::yum') }
|
||||||
:lsbdistcodename => 'precise',
|
end
|
||||||
:architecture => 'amd64',
|
end
|
||||||
}
|
end
|
||||||
}
|
|
||||||
it {
|
|
||||||
should contain_class('fluentd::repo::apt')
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when called with no parameters on osfamily RedHat' do
|
|
||||||
let(:facts) {
|
|
||||||
{
|
|
||||||
:osfamily => 'RedHat',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
it {
|
|
||||||
should contain_class('fluentd::repo::yum')
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@@ -1,27 +1,32 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe 'fluentd::repo::yum', :type => :class do
|
describe 'fluentd::repo::yum', :type => :class do
|
||||||
let(:facts) {
|
on_supported_os.each do |os, facts|
|
||||||
{
|
context "on #{os}" do
|
||||||
:osfamily => 'RedHat',
|
let :facts do
|
||||||
}
|
facts
|
||||||
}
|
end
|
||||||
|
|
||||||
describe 'when called with no parameters on RedHat' do
|
describe 'when called with no parameters' do
|
||||||
it {
|
case facts[:osfamily]
|
||||||
should contain_yumrepo('treasure-data').with({
|
when 'RedHat'
|
||||||
'ensure' => 'present',
|
it {
|
||||||
'baseurl' => 'https://packages.treasuredata.com/2/redhat/$releasever/$basearch',
|
should contain_yumrepo('treasure-data').with({
|
||||||
'descr' => 'TreasureData',
|
'ensure' => 'present',
|
||||||
'enabled' => '1',
|
'baseurl' => 'https://packages.treasuredata.com/2/redhat/$releasever/$basearch',
|
||||||
'gpgcheck' => '1'
|
'descr' => 'TreasureData',
|
||||||
}).that_notifies('Exec[add GPG key]')
|
'enabled' => '1',
|
||||||
|
'gpgcheck' => '1'
|
||||||
|
}).that_notifies('Exec[add GPG key]')
|
||||||
|
|
||||||
should contain_exec('add GPG key').with({
|
should contain_exec('add GPG key').with({
|
||||||
'command' => 'rpm --import https://packages.treasuredata.com/GPG-KEY-td-agent',
|
'command' => 'rpm --import https://packages.treasuredata.com/GPG-KEY-td-agent',
|
||||||
'path' => '/bin:/usr/bin/',
|
'path' => '/bin:/usr/bin/',
|
||||||
'refreshonly' => 'true'
|
'refreshonly' => 'true'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@@ -1,39 +1,23 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe 'fluentd::config', :type => :class do
|
describe 'fluentd::config', :type => :class do
|
||||||
shared_examples 'when called with no parameters' do
|
on_supported_os.each do |os, facts|
|
||||||
it {
|
context "on #{os}" do
|
||||||
should contain_service('fluentd').with({
|
let :facts do
|
||||||
'name' => 'td-agent',
|
facts
|
||||||
'ensure' => 'running',
|
end
|
||||||
'enable' => 'true',
|
|
||||||
'hasstatus' => 'true',
|
|
||||||
'hasrestart' => 'true'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when osfamily is Debian' do
|
describe 'when called with no parameters' do
|
||||||
let(:facts) {
|
it {
|
||||||
{
|
should contain_service('fluentd').with({
|
||||||
:osfamily => 'Debian',
|
'name' => 'td-agent',
|
||||||
:lsbdistid => 'Ubuntu',
|
'ensure' => 'running',
|
||||||
:operatingsystem => 'Ubuntu',
|
'enable' => 'true',
|
||||||
:lsbdistcodename => 'precise',
|
'hasstatus' => 'true',
|
||||||
:architecture => 'amd64',
|
'hasrestart' => 'true'
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
end
|
||||||
include_examples 'when called with no parameters'
|
end
|
||||||
end
|
|
||||||
|
|
||||||
context 'when osfamily is RedHat' do
|
|
||||||
let(:facts) {
|
|
||||||
{
|
|
||||||
:osfamily => 'RedHat',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
include_examples 'when called with no parameters'
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@@ -1,37 +1,20 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe 'fluentd', :type => :class do
|
describe 'fluentd', :type => :class do
|
||||||
shared_examples 'when called with no parameters' do
|
on_supported_os.each do |os, facts|
|
||||||
it {
|
context "on #{os}" do
|
||||||
should contain_class('fluentd::repo')
|
let :facts do
|
||||||
should contain_class('fluentd::install')
|
facts
|
||||||
should contain_class('fluentd::config')
|
end
|
||||||
should contain_class('fluentd::service')
|
|
||||||
}
|
describe 'when called with no parameters' do
|
||||||
|
it {
|
||||||
|
should contain_class('fluentd::repo')
|
||||||
|
should contain_class('fluentd::install')
|
||||||
|
should contain_class('fluentd::config')
|
||||||
|
should contain_class('fluentd::service')
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when osfamily is Debian' do
|
|
||||||
let(:facts) {
|
|
||||||
{
|
|
||||||
:osfamily => 'Debian',
|
|
||||||
:lsbdistid => 'Ubuntu',
|
|
||||||
:operatingsystem => 'Ubuntu',
|
|
||||||
:lsbdistcodename => 'precise',
|
|
||||||
:architecture => 'amd64',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
include_examples 'when called with no parameters'
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when osfamily is RedHat' do
|
|
||||||
let(:facts) {
|
|
||||||
{
|
|
||||||
:osfamily => 'RedHat',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
include_examples 'when called with no parameters'
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@@ -1,37 +1,21 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe 'fluentd::user', :type => :class do
|
describe 'fluentd::user', :type => :class do
|
||||||
shared_examples 'when called with no parameters' do
|
on_supported_os.each do |os, facts|
|
||||||
it {
|
context "on #{os}" do
|
||||||
should contain_user('fluentd').with({
|
let :facts do
|
||||||
'name' => 'td-agent',
|
facts
|
||||||
'gid' => 'td-agent',
|
end
|
||||||
'groups' => ['adm']
|
|
||||||
})
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when osfamily is Debian' do
|
describe 'when called with no parameters' do
|
||||||
let(:facts) {
|
it {
|
||||||
{
|
should contain_user('fluentd').with({
|
||||||
:osfamily => 'Debian',
|
'name' => 'td-agent',
|
||||||
:lsbdistid => 'Ubuntu',
|
'gid' => 'td-agent',
|
||||||
:operatingsystem => 'Ubuntu',
|
'groups' => ['adm']
|
||||||
:lsbdistcodename => 'precise',
|
})
|
||||||
:architecture => 'amd64',
|
}
|
||||||
}
|
end
|
||||||
}
|
end
|
||||||
|
|
||||||
include_examples 'when called with no parameters'
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when osfamily is RedHat' do
|
|
||||||
let(:facts) {
|
|
||||||
{
|
|
||||||
:osfamily => 'RedHat',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
include_examples 'when called with no parameters'
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@@ -1,40 +1,34 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe 'fluentd::filter' do
|
describe 'fluentd::filter' do
|
||||||
let(:facts) {
|
on_supported_os.each do |os, facts|
|
||||||
{
|
context "on #{os}" do
|
||||||
:osfamily => 'Debian',
|
let :facts do
|
||||||
:lsbdistid => 'Ubuntu',
|
facts
|
||||||
:operatingsystem => 'Ubuntu',
|
end
|
||||||
:lsbdistcodename => 'precise',
|
|
||||||
:architecture => 'amd64',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let(:pre_condition) { 'include fluentd' }
|
|
||||||
|
|
||||||
context 'basic filter' do
|
let(:pre_condition) { 'include fluentd' }
|
||||||
let(:title) { 'test' }
|
|
||||||
let(:params) do
|
describe 'basic filter' do
|
||||||
{
|
let(:title) { 'test' }
|
||||||
priority: '20',
|
let(:params) do
|
||||||
pattern: '*.test',
|
{
|
||||||
config: {
|
priority: 20,
|
||||||
|
pattern: '*.test',
|
||||||
|
config: {
|
||||||
'type' => 'record_transformer',
|
'type' => 'record_transformer',
|
||||||
'record' => {
|
'record' => {
|
||||||
'hostname' => '${hostname}'
|
'hostname' => '${hostname}'
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
end
|
||||||
end
|
|
||||||
|
|
||||||
it do
|
it do
|
||||||
is_expected.to contain_file('/etc/td-agent/conf.d/20-filter-test.conf').
|
is_expected.to contain_file('/etc/td-agent/conf.d/20-filter-test.conf').
|
||||||
with_content(/<filter \*.test>/).
|
with_content(IO.read(File.join(File.dirname(__FILE__), '../fixtures/files/filter_record_transformer.conf')))
|
||||||
with_content(/type record_transformer/).
|
end
|
||||||
with_content(/<record>/).
|
end
|
||||||
with_content(/hostname \$\{hostname\}/).
|
|
||||||
with_content(/<\/record>/).
|
|
||||||
with_content(/<\/filter>/)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@@ -1,94 +1,71 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe 'fluentd::match' do
|
describe 'fluentd::match' do
|
||||||
let(:facts) {
|
on_supported_os.each do |os, facts|
|
||||||
{
|
context "on #{os}" do
|
||||||
:osfamily => 'Debian',
|
let :facts do
|
||||||
:lsbdistid => 'Ubuntu',
|
facts
|
||||||
:operatingsystem => 'Ubuntu',
|
end
|
||||||
:lsbdistcodename => 'precise',
|
|
||||||
:architecture => 'amd64',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let(:pre_condition) { 'include fluentd' }
|
|
||||||
|
|
||||||
context 'basic match' do
|
let(:pre_condition) { 'include fluentd' }
|
||||||
let(:title) { 'test' }
|
|
||||||
let(:params) do
|
describe 'basic match' do
|
||||||
{
|
let(:title) { 'test' }
|
||||||
priority: '30',
|
let(:params) do
|
||||||
pattern: '*.test',
|
{
|
||||||
config: {
|
priority: 30,
|
||||||
'flush_interval' => '30s',
|
pattern: '*.test',
|
||||||
'type' => 'secure_forward',
|
config: {
|
||||||
'secure' => 'yes',
|
'flush_interval' => '30s',
|
||||||
'shared_key' => 'my_shared_key',
|
'type' => 'secure_forward',
|
||||||
'self_hostname' => 'instance.test.com',
|
'secure' => 'yes',
|
||||||
'ca_cert_path' => '/path/to/ca.cert',
|
'shared_key' => 'my_shared_key',
|
||||||
'server' => [
|
'self_hostname' => 'instance.test.com',
|
||||||
{
|
'ca_cert_path' => '/path/to/ca.cert',
|
||||||
'host' => 'test.server.com',
|
'server' => [
|
||||||
}
|
{
|
||||||
]
|
'host' => 'test.server.com',
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
end
|
||||||
end
|
|
||||||
|
|
||||||
it do
|
it do
|
||||||
is_expected.to contain_file('/etc/td-agent/conf.d/30-match-test.conf').
|
is_expected.to contain_file('/etc/td-agent/conf.d/30-match-test.conf').
|
||||||
with_content(/<match \*.test>/).
|
with_content(IO.read(File.join(File.dirname(__FILE__), '../fixtures/files/match_secure_forward.conf')))
|
||||||
with_content(/flush_interval 30s/).
|
end
|
||||||
with_content(/type secure_forward/).
|
end
|
||||||
with_content(/secure yes/).
|
|
||||||
with_content(/shared_key my_shared_key/).
|
|
||||||
with_content(/self_hostname instance.test.com/).
|
|
||||||
with_content(/ca_cert_path \/path\/to\/ca.cert/).
|
|
||||||
with_content(/<server>/).
|
|
||||||
with_content(/host test.server.com/).
|
|
||||||
with_content(/<\/server>/).
|
|
||||||
with_content(/<\/match>/)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'multiple store' do
|
describe 'multiple store' do
|
||||||
let(:title) { 'test' }
|
let(:title) { 'test' }
|
||||||
let(:params) do
|
let(:params) do
|
||||||
{
|
{
|
||||||
priority: '30',
|
priority: 30,
|
||||||
pattern: '*.test',
|
pattern: '*.test',
|
||||||
config: {
|
config: {
|
||||||
'type' => 'copy',
|
'type' => 'copy',
|
||||||
'store' => [
|
'store' => [
|
||||||
{
|
{
|
||||||
'type' => 'elasticsearch',
|
'type' => 'elasticsearch',
|
||||||
'logstashformat' => true,
|
'logstashformat' => true,
|
||||||
'hosts' => '172.20.10.17:9200',
|
'hosts' => '172.20.10.17:9200',
|
||||||
'flush_interval' => '30s',
|
'flush_interval' => '30s',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'type' => 'file',
|
'type' => 'file',
|
||||||
'path' => '/tmp/td-agent-debug.log',
|
'path' => '/tmp/td-agent-debug.log',
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
end
|
||||||
end
|
|
||||||
|
|
||||||
it do
|
it do
|
||||||
is_expected.to contain_file('/etc/td-agent/conf.d/30-match-test.conf').
|
is_expected.to contain_file('/etc/td-agent/conf.d/30-match-test.conf').
|
||||||
with_content(/<match \*.test>/).
|
with_content(IO.read(File.join(File.dirname(__FILE__), '../fixtures/files/match_copy.conf')))
|
||||||
with_content(/type copy/).
|
end
|
||||||
with_content(/<store>/).
|
end
|
||||||
with_content(/type elasticsearch/).
|
|
||||||
with_content(/logstashformat true/).
|
|
||||||
with_content(/hosts 172.20.10.17:9200/).
|
|
||||||
with_content(/flush_interval 30s/).
|
|
||||||
with_content(/<\/store>/).
|
|
||||||
with_content(/<store>/).
|
|
||||||
with_content(/type file/).
|
|
||||||
with_content(/path \/tmp\/td-agent-debug.log/).
|
|
||||||
with_content(/<\/store>/).
|
|
||||||
with_content(/<\/match>/)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@@ -1,52 +1,51 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe 'fluentd::plugin' do
|
describe 'fluentd::plugin' do
|
||||||
let(:facts) {
|
on_supported_os.each do |os, facts|
|
||||||
{
|
context "on #{os}" do
|
||||||
:osfamily => 'Debian',
|
let :facts do
|
||||||
:lsbdistid => 'Ubuntu',
|
facts
|
||||||
:operatingsystem => 'Ubuntu',
|
end
|
||||||
:lsbdistcodename => 'precise',
|
|
||||||
:architecture => 'amd64',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let(:pre_condition) { 'include fluentd' }
|
|
||||||
|
|
||||||
context 'gem plugin' do
|
let(:pre_condition) { 'include fluentd' }
|
||||||
let(:title) { 'fluent-plugin-elasticsearch' }
|
|
||||||
let(:params) do
|
|
||||||
{
|
|
||||||
type: 'gem'
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
it do
|
describe 'gem plugin' do
|
||||||
should contain_package('fluent-plugin-elasticsearch').with({
|
let(:title) { 'fluent-plugin-elasticsearch' }
|
||||||
'ensure' => 'present',
|
let(:params) do
|
||||||
'provider' => 'fluentd_gem',
|
{
|
||||||
'notify' => 'Class[Fluentd::Service]'
|
type: 'gem'
|
||||||
})
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
it do
|
||||||
|
should contain_package('fluent-plugin-elasticsearch').with({
|
||||||
|
'ensure' => 'present',
|
||||||
|
'provider' => 'fluentd_gem',
|
||||||
|
'notify' => 'Class[Fluentd::Service]'
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'file plugin' do
|
||||||
|
let(:title) { 'fluent-plugin-test' }
|
||||||
|
let(:params) do
|
||||||
|
{
|
||||||
|
type: 'file',
|
||||||
|
source: 'puppet:///path/to/source'
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
it do
|
||||||
|
should contain_file('/etc/td-agent/plugin/fluent-plugin-test').with({
|
||||||
|
'ensure' => 'present',
|
||||||
|
'owner' => 'td-agent',
|
||||||
|
'group' => 'td-agent',
|
||||||
|
'mode' => '0640',
|
||||||
|
'source' => 'puppet:///path/to/source',
|
||||||
|
'notify' => 'Class[Fluentd::Service]'
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
context 'file plugin' do
|
|
||||||
let(:title) { 'fluent-plugin-test' }
|
|
||||||
let(:params) do
|
|
||||||
{
|
|
||||||
type: 'file',
|
|
||||||
source: 'puppet:///path/to/source'
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
it do
|
|
||||||
should contain_file('/etc/td-agent/plugin/fluent-plugin-test').with({
|
|
||||||
'ensure' => 'present',
|
|
||||||
'owner' => 'td-agent',
|
|
||||||
'group' => 'td-agent',
|
|
||||||
'mode' => '0640',
|
|
||||||
'source' => 'puppet:///path/to/source',
|
|
||||||
'notify' => 'Class[Fluentd::Service]'
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
@@ -1,39 +1,41 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe 'fluentd::source' do
|
describe 'fluentd::source' do
|
||||||
let(:facts) {
|
on_supported_os.each do |os, facts|
|
||||||
{
|
context "on #{os}" do
|
||||||
:osfamily => 'Debian',
|
let :facts do
|
||||||
:lsbdistid => 'Ubuntu',
|
facts
|
||||||
:operatingsystem => 'Ubuntu',
|
end
|
||||||
:lsbdistcodename => 'precise',
|
|
||||||
:architecture => 'amd64',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let(:pre_condition) { 'include fluentd' }
|
|
||||||
|
|
||||||
context 'basic source' do
|
let(:pre_condition) { 'include fluentd' }
|
||||||
let(:title) { 'test' }
|
|
||||||
let(:params) do
|
describe 'basic source' do
|
||||||
{
|
let(:title) { 'test' }
|
||||||
priority: '10',
|
let(:params) do
|
||||||
config: {
|
{
|
||||||
'type' => 'tail',
|
priority: 10,
|
||||||
'format' => 'json',
|
config: {
|
||||||
'path' => '/var/log/test-application/*.json',
|
'type' => 'tail',
|
||||||
'tag' => 'application.test'
|
'format' => 'json',
|
||||||
|
'path' => '/var/log/test-application/*.json',
|
||||||
|
'parse' => {
|
||||||
|
'type' => 'regexp',
|
||||||
|
'expression' => '^(?<name>[^ ]*) (?<user>[^ ]*) (?<age>\d*)$'
|
||||||
|
},
|
||||||
|
'storage'=> {
|
||||||
|
'type' => 'local',
|
||||||
|
'path' => 'test.pos'
|
||||||
|
},
|
||||||
|
'tag' => 'application.test'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
end
|
||||||
end
|
|
||||||
|
|
||||||
it do
|
it do
|
||||||
is_expected.to contain_file('/etc/td-agent/conf.d/10-source-test.conf').
|
is_expected.to contain_file('/etc/td-agent/conf.d/10-source-test.conf').
|
||||||
with_content(/<source>/).
|
with_content(IO.read(File.join(File.dirname(__FILE__), '../fixtures/files/source_tail.conf')))
|
||||||
with_content(/type tail/).
|
end
|
||||||
with_content(/format json/).
|
end
|
||||||
with_content(/path \/var\/log\/test-application\/\*.json/).
|
|
||||||
with_content(/tag application.test/).
|
|
||||||
with_content(/<\/source>/)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
6
spec/fixtures/files/filter_record_transformer.conf
vendored
Normal file
6
spec/fixtures/files/filter_record_transformer.conf
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<filter *.test>
|
||||||
|
type record_transformer
|
||||||
|
<record>
|
||||||
|
hostname ${hostname}
|
||||||
|
</record>
|
||||||
|
</filter>
|
13
spec/fixtures/files/match_copy.conf
vendored
Normal file
13
spec/fixtures/files/match_copy.conf
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<match *.test>
|
||||||
|
type copy
|
||||||
|
<store>
|
||||||
|
type elasticsearch
|
||||||
|
logstashformat true
|
||||||
|
hosts 172.20.10.17:9200
|
||||||
|
flush_interval 30s
|
||||||
|
</store>
|
||||||
|
<store>
|
||||||
|
type file
|
||||||
|
path /tmp/td-agent-debug.log
|
||||||
|
</store>
|
||||||
|
</match>
|
11
spec/fixtures/files/match_secure_forward.conf
vendored
Normal file
11
spec/fixtures/files/match_secure_forward.conf
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<match *.test>
|
||||||
|
flush_interval 30s
|
||||||
|
type secure_forward
|
||||||
|
secure yes
|
||||||
|
shared_key my_shared_key
|
||||||
|
self_hostname instance.test.com
|
||||||
|
ca_cert_path /path/to/ca.cert
|
||||||
|
<server>
|
||||||
|
host test.server.com
|
||||||
|
</server>
|
||||||
|
</match>
|
14
spec/fixtures/files/source_tail.conf
vendored
Normal file
14
spec/fixtures/files/source_tail.conf
vendored
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<source>
|
||||||
|
type tail
|
||||||
|
format json
|
||||||
|
path /var/log/test-application/*.json
|
||||||
|
<parse>
|
||||||
|
type regexp
|
||||||
|
expression ^(?<name>[^ ]*) (?<user>[^ ]*) (?<age>\d*)$
|
||||||
|
</parse>
|
||||||
|
<storage>
|
||||||
|
type local
|
||||||
|
path test.pos
|
||||||
|
</storage>
|
||||||
|
tag application.test
|
||||||
|
</source>
|
@@ -1 +1,3 @@
|
|||||||
require 'puppetlabs_spec_helper/module_spec_helper'
|
require 'puppetlabs_spec_helper/module_spec_helper'
|
||||||
|
require 'rspec-puppet-facts'
|
||||||
|
include RspecPuppetFacts
|
||||||
|
@@ -1,13 +1,13 @@
|
|||||||
<filter <%= @pattern %>>
|
<filter <%= @pattern %>>
|
||||||
<% @config.each do |key, val| -%>
|
<% @config.each do |key, val| -%>
|
||||||
<%- if val.is_a?( Hash ) -%>
|
<%- if val.is_a?( Hash ) -%>
|
||||||
<<%= key -%>>
|
<<%= key -%>>
|
||||||
<%- val.each do |key2, val2| -%>
|
<%- val.each do |key2, val2| -%>
|
||||||
<%= key2 -%> <%= val2 %>
|
<%= key2 -%> <%= val2 %>
|
||||||
<%- end -%>
|
<%- end -%>
|
||||||
</<%= key %>>
|
</<%= key %>>
|
||||||
<%- else -%>
|
<%- else -%>
|
||||||
<%= key -%> <%= val %>
|
<%= key -%> <%= val %>
|
||||||
<%- end -%>
|
<%- end -%>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
</filter>
|
</filter>
|
||||||
|
@@ -1,39 +1,39 @@
|
|||||||
<match <%= @pattern %>>
|
<match <%= @pattern %>>
|
||||||
<% @config.each do |key, val| -%>
|
<% @config.each do |key, val| -%>
|
||||||
<%- if val.is_a?( Hash ) -%>
|
<%- if val.is_a?( Hash ) -%>
|
||||||
<<%= key -%>>
|
<<%= key -%>>
|
||||||
<%- val.each do |key, val| -%>
|
<%- val.each do |key, val| -%>
|
||||||
<%= key -%> <%= val %>
|
<%= key -%> <%= val %>
|
||||||
<%- end -%>
|
<%- end -%>
|
||||||
</<%= key %>>
|
</<%= key %>>
|
||||||
<%- elsif val.is_a?( Array ) -%>
|
<%- elsif val.is_a?( Array ) -%>
|
||||||
<%- val.each do |k, v| -%>
|
<%- val.each do |k, v| -%>
|
||||||
<<%= key -%>>
|
<<%= key -%>>
|
||||||
<%- if k.is_a?( Hash ) -%>
|
<%- if k.is_a?( Hash ) -%>
|
||||||
<%- k.each do |x, y| -%>
|
<%- k.each do |x, y| -%>
|
||||||
<%- if y.is_a?( Array ) -%>
|
<%- if y.is_a?( Array ) -%>
|
||||||
<%- y.each do |a, b| -%>
|
<%- y.each do |a, b| -%>
|
||||||
<<%= x -%>>
|
<<%= x -%>>
|
||||||
<%- if a.is_a?( Hash ) -%>
|
<%- if a.is_a?( Hash ) -%>
|
||||||
<%- a.each do |c, d| -%>
|
<%- a.each do |c, d| -%>
|
||||||
<%= c -%> <%= d %>
|
<%= c -%> <%= d %>
|
||||||
<%- end -%>
|
<%- end -%>
|
||||||
<%- else -%>
|
<%- else -%>
|
||||||
<%= a -%> <%= b %>
|
<%= a -%> <%= b %>
|
||||||
<%- end -%>
|
<%- end -%>
|
||||||
</<%= x %>>
|
</<%= x %>>
|
||||||
<%- end -%>
|
|
||||||
<%- else -%>
|
|
||||||
<%= x -%> <%= y %>
|
|
||||||
<%- end -%>
|
|
||||||
<%- end -%>
|
|
||||||
<%- else -%>
|
|
||||||
<%= k -%> <%= v %>
|
|
||||||
<%- end -%>
|
|
||||||
</<%= key %>>
|
|
||||||
<%- end -%>
|
|
||||||
<%- else -%>
|
|
||||||
<%= key -%> <%= val %>
|
|
||||||
<%- end -%>
|
<%- end -%>
|
||||||
|
<%- else -%>
|
||||||
|
<%= x -%> <%= y %>
|
||||||
|
<%- end -%>
|
||||||
|
<%- end -%>
|
||||||
|
<%- else -%>
|
||||||
|
<%= k -%> <%= v %>
|
||||||
|
<%- end -%>
|
||||||
|
</<%= key %>>
|
||||||
|
<%- end -%>
|
||||||
|
<%- else -%>
|
||||||
|
<%= key -%> <%= val %>
|
||||||
|
<%- end -%>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
</match>
|
</match>
|
||||||
|
@@ -1,5 +1,13 @@
|
|||||||
<source>
|
<source>
|
||||||
<% @config.each do |key, val| -%>
|
<% @config.each do |key, val| -%>
|
||||||
<%= key -%> <%= val %>
|
<%- if val.is_a?( Hash ) -%>
|
||||||
|
<<%= key -%>>
|
||||||
|
<%- val.each do |key2, val2| -%>
|
||||||
|
<%= key2 -%> <%= val2 %>
|
||||||
|
<%- end -%>
|
||||||
|
</<%= key %>>
|
||||||
|
<%- else -%>
|
||||||
|
<%= key -%> <%= val %>
|
||||||
|
<%- end -%>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
</source>
|
</source>
|
||||||
|
Reference in New Issue
Block a user