1
0
mirror of https://github.com/krislamo/puppet-fluentd synced 2025-09-13 08:59:29 +00:00

59 Commits
0.3.0 ... 0.5.5

Author SHA1 Message Date
Max Wilhelm
3f26736084 prepare 0.5.5 2017-07-25 15:17:22 +02:00
Max Wilhelm
d27479eb17 Merge pull request #15 from lzecca78/master
added boolean param for enabling fluentd::conf_dir
2017-07-25 15:13:28 +02:00
Luca Zecca
c8046ee2c6 added boolean param for enabling fluentd::conf_dir exclusive file handling by puppet. 2017-07-24 14:33:21 +02:00
Max Wilhelm
fc94e7ba6f prepare 0.5.4 2017-07-11 11:25:10 +02:00
Nicanor Gutierrez
3fb5293880 Fix formatting 2017-07-11 11:13:23 +02:00
Nicanor Gutierrez
e5650f47d1 Add path to exec to avoid error
Error received before: Error: Failed to apply catalog: Parameter onlyif failed on Exec[remove old GPG key]: 'rpm -qi gpg-pubkey-a12e206f-*' is not qualified and no path was specified. Please qualify the command or specify a path. at /etc/puppetlabs/code/environments/acceptance/modules/fluentd/manifests/repo/yum.pp:27
2017-07-11 11:13:23 +02:00
sgudmand
49848b2afd Change variable names for inner loop in filter.erb
When using the module with puppet 3.8.7, ran into an issue where the variable assignment of the inner loop was overwriting the variables of the same name in the outer loop.  This was causing filter configs to be generated with an unmatched record tag.  I have simply changed the names of the variables in the inner loop of the template so that the will no longer occur.
2017-07-11 11:13:11 +02:00
Max Wilhelm
f4c24ee881 fixed lint warnings 2017-07-11 10:53:53 +02:00
Max Wilhelm
2e789170a0 puppet lint configuration 2017-07-11 10:53:53 +02:00
Max Wilhelm
22a9578a88 drop support for ruby 1.9.3
EOL since February 23, 2015
2017-07-11 10:53:53 +02:00
Christian Becker
9eb19b3d1b prepare 0.5.3 2017-01-19 14:50:13 +01:00
Christian Becker
6a05cae33e Merge pull request #10 from lobeck/master
update tresuredata GPG key
2017-01-19 14:47:47 +01:00
Christian Becker
2183f670f2 change tresuredata GPG key
http://www.fluentd.org/blog/update-gpg-key-for-td-agent
2017-01-19 14:40:44 +01:00
Christian Becker
bcad5ca42c Merge pull request #11 from lobeck/gem_fix
fix public_suffix gem for ruby < 2.0
2017-01-19 14:25:40 +01:00
Christian Becker
26694848cb fix gems for ruby < 2.0
- pinned to older versions which are still compatible
- newer rubies will install the latest versions
2017-01-02 17:13:16 +01:00
Max Wilhelm
bb2346df50 prepare 0.5.2 release 2016-07-14 11:22:44 +02:00
Max Wilhelm
e062d4f2e0 disable_puppet_url_without_modules for puppet-lint 2016-07-14 11:12:20 +02:00
Max Wilhelm
f32ea2c0ba try to fix build 2016-07-14 10:56:34 +02:00
Max Wilhelm
8081e8df20 Merge pull request #9 from pdrakeweb/fix-parameter-docs
Correct the docs related to the service_enable parameter.
2016-07-14 10:55:58 +02:00
Peter Drake
6cb1364023 Correct the docs related to the service_enable parameter. 2016-07-13 15:55:55 -04:00
Max Wilhelm
3dab36ee83 prepare 0.5.1 release 2016-05-13 10:18:52 +02:00
Max Wilhelm
8916d18654 Merge pull request #8 from mhrabovcin/master
Allow to install specific version of fluent plugins
2016-05-13 10:16:40 +02:00
Martin Hrabovcin
75a537432c Fix tests for Puppet 4 2016-05-12 22:31:52 +02:00
Martin Hrabovcin
9754e64490 Allow to install specific version of fluent plugins 2016-05-11 18:32:31 +02:00
Max Wilhelm
6b915de23c prepare 0.5.0 release 2016-01-27 21:05:34 +01:00
Max Wilhelm
3797e70098 added metadata-json-lint to Gemfile 2016-01-27 20:46:23 +01:00
Max Wilhelm
9c34a6cbf6 added gem plugin installation to acceptance test 2016-01-27 20:12:28 +01:00
Max Wilhelm
9f79619a08 fixed typeo in README 2016-01-27 18:25:36 +01:00
Max Wilhelm
89287cc828 updated README 2016-01-27 13:43:34 +01:00
Max Wilhelm
3e36e94971 added CentOS to operatingsystem_support 2016-01-27 12:56:49 +01:00
Max Wilhelm
ae7256a8c2 added context to class spec tests to be able to test osfamily RedHat 2016-01-27 12:45:27 +01:00
Max Wilhelm
be1a555591 added spec test for fluentd::repo::yum 2016-01-27 12:42:11 +01:00
Max Wilhelm
3ef403cf65 add nodesets for centos 6 & 7 2016-01-27 12:00:35 +01:00
Max Wilhelm
9900e8f172 fixed path for 'add GPG key' exec 2016-01-27 11:59:00 +01:00
Max Wilhelm
7ddbe46025 Merge pull request #1 from ume3/add-redhat-repository-support
added redhat(yumrepo) support
2016-01-27 10:06:38 +01:00
ume3
e3e4b9bd61 add: an $ensure parameter
review:
https://github.com/wywygmbh/puppet-fluentd/pull/1#discussion-diff-50847623
refs:
http://docs.puppetlabs.com/puppet/latest/reference/type.html#yumrepo-attribute-ensure
2016-01-27 11:35:43 +09:00
ume3
9aaccda9e0 del: not really needed included
review:
https://github.com/wywygmbh/puppet-fluentd/pull/1#discussion-diff-50847501
2016-01-27 11:18:07 +09:00
Max Wilhelm
2b86e57b7b fixed lint warning 2016-01-26 22:38:44 +01:00
Max Wilhelm
b0000fc99b added include parameter to fluentd::repo::apt test 2016-01-26 22:20:26 +01:00
Max Wilhelm
08a27245f7 Merge branch 'master' of https://github.com/cotocisternas/puppet-fluentd
Conflicts:
	manifests/init.pp
	manifests/params.pp
	manifests/repo/apt.pp
2016-01-26 22:13:30 +01:00
Max Wilhelm
4c3f1f9a18 Revert "fixed travis build"
This reverts commit c39f88be0b.

Has been fixed with rspec-puppet version 2.3.2
2016-01-26 19:08:53 +01:00
Max Wilhelm
c39f88be0b fixed travis build
there seems to be a bing in rspec-puppet 2.3.1
https://github.com/rodjek/rspec-puppet/issues/353
2016-01-26 12:35:50 +01:00
ume3
b465108fcc added redhat(yumrepo) support
Check CentOS7.2(1511) / Redhat7.1
refs
 - https://td-agent-package-browser.herokuapp.com/2/redhat/
 - http://docs.puppetlabs.com/puppet/latest/reference/type.html#yumrepo
2016-01-26 18:07:01 +09:00
Max Wilhelm
567a07ebb2 fixed serverspec test for Debian 8
there seems to be a bug while checking for service enabled
2016-01-25 12:42:03 +01:00
Max Wilhelm
a6fbde8a4c fixed apt repo location 2016-01-23 00:33:16 +01:00
Max Wilhelm
471eb1bbf2 added debian support 2016-01-23 00:32:29 +01:00
Max Wilhelm
9eb93da056 cleanup beaker tests
- use beaker/puppet_install_helper to install puppet
- installed dependency modules like they are listed in the metadata.json
- changed apt repo source from https to http, https produced ssl errors under certain ruby versions and needs additional packages on some systems and the packages are signed anyways
2016-01-22 18:52:12 +01:00
Max Wilhelm
afc59cb27e renamed manage_repo to repo_manage
consistency
2016-01-22 18:50:04 +01:00
Coto Cisternas
490868d6b1 require => Exec['apt_update'] before install 2016-01-20 00:40:21 -03:00
Coto Cisternas
57740bc18d confine for provider 2016-01-16 00:15:58 -03:00
Coto Cisternas
e693af3c42 debian support, fix exec validations and repository 2016-01-15 17:35:19 -03:00
Max Wilhelm
2e5892663e fixed spec tests 2016-01-11 18:38:08 +01:00
Max Wilhelm
5da076c98a changed fluentd repo location from http to https 2016-01-11 18:37:09 +01:00
Max Wilhelm
c6e3a69f2b added first version of beaker tests (wip) 2016-01-11 18:36:45 +01:00
Max Wilhelm
d11007eb35 Update README.md 2015-12-22 14:05:49 +01:00
Max Wilhelm
7beb6b5298 added class parameters to README 2015-12-22 13:57:09 +01:00
Max Wilhelm
7821317f84 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/*.
2015-12-22 13:56:46 +01:00
Jan Krause
6a08c099c4 prepare 0.4.0 release 2015-12-11 10:52:35 +01:00
Jan Krause
88f021de43 allow repeating keys in match rules
extends the match template, yes, its not pretty
readable, to support array definitions for
defining multiple server or stores.
2015-12-11 10:21:27 +01:00
43 changed files with 775 additions and 128 deletions

View File

@@ -6,12 +6,16 @@ script: bundle exec rake validate && bundle exec rake lint && bundle exec rake s
matrix:
fast_finish: true
include:
- rvm: 1.9.3
env: PUPPET_GEM_VERSION="~> 3.0"
- rvm: 2.1.5
env: PUPPET_GEM_VERSION="~> 3.0"
- rvm: 2.1.6
env: PUPPET_GEM_VERSION="~> 4.0" STRICT_VARIABLES="yes"
- rvm: 2.1.10
env: PUPPET_VERSION="~> 3.0"
- rvm: 2.1.10
env: PUPPET_VERSION="~> 4.0" STRICT_VARIABLES="yes"
- rvm: 2.2.7
env: PUPPET_VERSION="~> 4.0" STRICT_VARIABLES="yes"
- rvm: 2.3.4
env: PUPPET_VERSION="~> 4.0" STRICT_VARIABLES="yes"
- rvm: 2.4.1
env: PUPPET_VERSION="~> 4.0" STRICT_VARIABLES="yes"
notifications:
slack:
secure: WVBx/OJqLpX9WXyiejEdnOcAf+5ShWJ2gcyeBCX032iKzPphcdPKqH+jnlFaKjqQCZARbRqzlj/if3FZWAlhWtTrWrcY545dRHcsaGvJ/nMtdHlBUuwUNHipSn+RTXtorsYz0efhJMPye2LMl0HgAp3rEs70XUt8rZOwdedLGVgfWRwM+KixhSf8P08v9QjNRNdhWII37KFRdqv/NHryNlVKsTLH6fQOyIvok3vrTvMR8rWMRETXv6JLpCJ3FfOrxo53fW7q+GlXXuVcQ2OGlgxm3eke6q2aXZAqczeB5CSlWgUEA5T3rQ//WI3enwTayRajV/9O26HZvASjSTnDRiSSv1itYqg1Uy6kuJy5ANpBizOyWY6/QTM5Rw00AXvaY9ur0EmyNe5vLNHyTxzdr4R+rXjE07yCDvWM9RGbu+4BipP+mAoJTkuCIP54FWYn1qOJnC8DYywD/+wniCNLbp6yMgbG/aC6H5RmuSy+3xRoEbwvyXKUgA+4gL3I3aAIvidBG+yazRBFvRCn4pUJdTEc4Cpu0jhQWXWyZSE66HNPKyIOXl9JPTzul08MDo9OaqBt+K3yeMVA8EPr196mWLwerF+dExQ2PJhUu/7MAiOgFrIr4/d05iKhj4ivLYBRNN317s2NVo8qyfhPHlfv6PyzhllC/qjClQ2rLOemVhg=

View File

@@ -1,4 +1,36 @@
# Changelog
## 0.5.5
* Added `conf_dir_manage` parameter (Default: false)
* Exclusively handle config files into fluentd::conf_dir. Other files not created by puppet, will be deleted
## 0.5.4
* fixed templates/filter.erb
* fixed removing of old GPG key for yum repos
## 0.5.3
* update treasure data repo gpg key
## 0.5.2
* Correct the docs related to the service_enable parameter
## 0.5.1
* Allow to install specific version of fluent gem plugins
## 0.5.0
* Added support for Debian 6, 7, 8
* Added support for CentOS 6, 7
* Added `::fluentd::user`, which manages the td-agent user
* Added parameter `user_manage`
* Added parameter `user_name`
* Added parameter `user_group`
* Added parameter `user_groups`
* Added acceptance tests
* `::fluentd::repo::apt::location default` changed to
`http://packages.treasuredata.com/2/${::lsbdistid}/${::lsbdistcodename}`
* Small fixes and improvements
## 0.4.0
* Allows definition of multiple directives in matching rules
## 0.3.0
* Increased apt dependency

16
Gemfile
View File

@@ -1,7 +1,21 @@
source 'https://rubygems.org'
puppetversion = ENV.key?('PUPPET_VERSION') ? "#{ENV['PUPPET_VERSION']}" : ['>= 3.3']
ENV['PUPPET_VERSION'].nil? ? puppetversion = '~> 4.0' : puppetversion = ENV['PUPPET_VERSION'].to_s
gem 'puppet', puppetversion
gem 'puppetlabs_spec_helper', '>= 0.8.2'
gem 'puppet-lint', '>= 1.0.0'
gem 'facter', '>= 1.7.0'
gem 'beaker-puppet_install_helper'
gem 'metadata-json-lint'
beakerrspec = '> 0'
platforms [:ruby_19, :ruby_21] do
beakerrspec = '<= 5.6.0'
end
gem 'beaker-rspec', beakerrspec
platforms :ruby_19 do
gem 'public_suffix', '< 1.5.0', :platforms => :ruby_19
gem 'nokogiri', '< 1.7.0', :platforms => :ruby_19
gem 'mime-types', '< 3.0', :platforms => :ruby_19
end

122
README.md
View File

@@ -11,9 +11,11 @@
1. [Setup - The basics of getting started with fluentd](#setup)
1. [Usage](#usage)
* [Configuration](#configuration)
* [Parameters](#parameters)
* [Source](#source)
* [Filter](#filter)
* [Match](#match)
* [Match Store](#match-store)
* [Plugin Installation](#plugin-installation)
* [Requirements](#requirements)
1. [Limitations - OS compatibility, etc.](#limitations)
@@ -40,6 +42,67 @@ include '::fluentd'
### Configuration
#### Parameters
`repo_manage`
Include repository to install recent fluentd (td-agent) from.
**Default:** 'true'
`package_ensure`
Package ensure.
**Default:** 'installed'
`package_name`
Package name.
**Default:** 'td-agent'
`package_install_options`
Package install options.
**Default:** '[]'
`service_manage`
Defines if the service should be managed by puppet.
**Default:** 'true'
`service_name`
Name of the service.
**Default:** 'td-agent'
`service_ensure`
Service ensure.
**Default:** 'running'
`service_enable`
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"]'
#### Source
```puppet
::fluentd::source { 'test':
@@ -97,9 +160,9 @@ include '::fluentd'
'shared_key' => 'my_shared_key',
'self_hostname' => 'instance.test.com',
'ca_cert_path' => '/path/to/ca.cert',
'servers' => {
'host' => 'test.server.com'
}
'server' => [{
'host' => 'test.server.com',
}]
}
}
```
@@ -113,9 +176,48 @@ include '::fluentd'
shared_key my_shared_key
self_hostname instance.test.com
ca_cert_path /path/to/ca.cert
<servers>
<server>
host test.server.com
</servers>
</server>
</match>
```
### Match Store
```puppet
::fluentd::match { 'test':
priority => 30,
pattern => '*.test',
config => {
'type' => 'copy',
'store' => [
{
'type' => 'elasticsearch',
'logstashformat' => true,
'hosts' => '172.20.10.17:9200',
'flush_interval' => '30s',
},
{
'type' => 'file',
'path' => '/tmp/td-agent-debug.log',
}
]
}
}
```
**creates:**
```
/etc/td-agent/conf.d/30-match-test.conf
<match *.test>
type copy
<store>
type elasticsearch
logstash_format true
hosts 172.20.10.17:9200
flush_interval 30s
</store>
<store>
type file
path /tmp/crs
</store>
</match>
```
@@ -126,7 +228,8 @@ This module gives you the possibility to install plugins as gem or files.
**gem installation**
```puppet
::fluentd::plugin { 'fluent-plugin-elasticsearch':
type => 'gem'
type => 'gem',
ensure => '0.1.3'
}
```
**file installation**
@@ -162,6 +265,13 @@ To run the tests install the ruby dependencies with `bundler` and execute
bundle install --path vendor/bundle
bundle exec rake spec
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=debian-60-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=centos-66-x64
bundle exec rake beaker BEAKER_set=centos-70-x64
```
## License

View File

@@ -1,7 +1,22 @@
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'
PuppetLint.configuration.send('disable_80chars')
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]
PuppetLint.configuration.log_format = '%{path}:%{line}:%{check}:%{KIND}:%{message}'
PuppetLint.configuration.fail_on_warnings = true
PuppetLint.configuration.send('relative')
PuppetLint.configuration.send('disable_140chars')
PuppetLint.configuration.send('disable_class_inherits_from_params_class')
PuppetLint.configuration.send('disable_documentation')
PuppetLint.configuration.send('disable_single_quote_string_with_variables')
exclude_paths = %w(
pkg/**/*
vendor/**/*
.vendor/**/*
spec/**/*
)
PuppetLint.configuration.ignore_paths = exclude_paths
PuppetSyntax.exclude_paths = exclude_paths
desc "Validate manifests, templates, and ruby files"
task :validate do

View File

@@ -9,8 +9,27 @@
'shared_key' => 'my_shared_key',
'self_hostname' => 'instance.test.com',
'ca_cert_path' => '/path/to/ca.cert',
'servers' => {
'host' => 'test.server.com'
'server' => [{
'host' => 'test.server.com',
}]
}
}
::fluentd::match { 'test':
priority => 30,
pattern => '*.test',
config => {
'type' => 'copy',
'store' => [{
'type' => 'elasticsearch',
'logstashformat' => true,
'hosts' => '172.20.10.17:9200',
'flush_interval' => '30s',
},
{
'type' => 'file',
'path' => '/tmp/td-agent-debug.log',
}
]
}
}

View File

@@ -5,5 +5,5 @@
# file installation
::fluentd::plugin { 'fluent-plugin-elasticsearch':
type => 'file',
source => 'puppet:///path/to/plugin'
source => 'puppet:///modules/path/to/plugin'
}

10
examples/test.pp Normal file
View File

@@ -0,0 +1,10 @@
# This file is use for the beaker tests.
# basic installation
include '::fluentd'
# install a gem plugin
::fluentd::plugin { 'fluent-plugin-elasticsearch':
type => 'gem',
require => Class['::fluentd']
}

View File

@@ -8,6 +8,7 @@ Puppet::Type.type(:package).provide :fluentd_gem, :parent => :gem do
not a valid URL, it will be interpreted as the path to a local gem file. If
source is not present at all, the gem will be installed from the default gem
repositories."
confine :exists => "/opt/td-agent/embedded/bin/gem"
has_feature :versionable, :install_options

View File

@@ -12,6 +12,8 @@ class fluentd::config inherits fluentd {
file { $::fluentd::conf_dir:
ensure => 'directory',
recurse => $::fluentd::params::conf_dir_manage,
purge => $::fluentd::params::conf_dir_manage,
owner => $::fluentd::user_name,
group => $::fluentd::user_group,
mode => '0750',

View File

@@ -17,8 +17,10 @@ define fluentd::config::file (
# clean up to ensure priority changes take effect
exec { "apply priority change for ${base_name}":
command => "rm ${::fluentd::conf_dir}/*-${base_name}",
onlyif => "ls ${::fluentd::conf_dir}/*-${base_name} | grep -v ${config_name}",
path => '/bin:/usr/bin:/usr/local/bin',
cwd => $::fluentd::conf_dir,
command => "rm *-${base_name}",
onlyif => "ls *-${base_name} | grep -v ${config_name}",
before => File[$config_path],
notify => Class['Fluentd::Service'],
}

View File

@@ -5,9 +5,12 @@
#
# Parameters
# ----------
# [*manage_repo*]
# [*repo_manage*]
# Include repository to install recent fluentd (td-agent) from
# 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
# Default: 'installed'
@@ -26,8 +29,20 @@
# [*service_ensure*]
# Service ensure
# Default: 'running'
# [*service_enabled*]
# Defines if the service should be enabled, defaults to 'true'
# [*service_enable*]
# 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
# --------
@@ -41,7 +56,7 @@
# Copyright 2015 wywy GmbH, unless otherwise noted.
#
class fluentd (
$manage_repo = $::fluentd::params::manage_repo,
$repo_manage = $::fluentd::params::repo_manage,
$package_ensure = $::fluentd::params::package_ensure,
$package_name = $::fluentd::params::package_name,
$package_install_options = $::fluentd::params::package_install_options,
@@ -51,13 +66,16 @@ class fluentd (
$service_enable = $::fluentd::params::service_enable,
$config_path = $::fluentd::params::config_path,
$conf_dir = $::fluentd::params::conf_dir,
$conf_dir_manage = $::fluentd::params::conf_dir_manage,
$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
validate_bool($manage_repo)
validate_bool($repo_manage)
validate_string($package_ensure)
validate_string($package_name)
validate_array($package_install_options)
@@ -72,12 +90,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::Config'] ->
Class['::Fluentd::Service']
Class['::Fluentd::Repo']
-> Class['::Fluentd::Install']
-> Class['::Fluentd::User']
-> Class['::Fluentd::Config']
-> Class['::Fluentd::Service']
}

View File

@@ -31,9 +31,9 @@
# 'shared_key' => 'my_shared_key',
# 'self_hostname' => 'instance.test.com',
# 'ca_cert_path' => '/path/to/ca.cert',
# 'servers' => {
# 'server' => [{
# 'host' => 'test.server.com'
# }
# }]
# }
# }
#

View File

@@ -11,21 +11,20 @@ class fluentd::params {
# config params
$config_path = '/etc/td-agent'
$conf_dir = "${config_path}/conf.d"
$conf_dir_manage = false
$config_file = "${config_path}/td-agent.conf"
# user params
$user_manage = true
$user_name = 'td-agent'
$user_group = 'td-agent'
$user_groups = ['adm']
case $::osfamily {
'Debian': {
case $::operatingsystem {
'Ubuntu': {
$manage_repo = true
}
default: {
fail("Unsupported osfamily: ${::operatingsystem}")
}
$repo_manage = true
}
'Redhat': {
$repo_manage = true
}
default: {
fail("Unsupported osfamily: ${::osfamily}")

View File

@@ -31,11 +31,6 @@ define fluentd::plugin (
$source = undef,
) {
# parameter validation
if ! ($ensure in [ 'present', 'absent' ]) {
fail('ensure parameter must be present or absent')
}
case $type {
'gem': {
fluentd::plugin::gem { $name:
@@ -44,6 +39,10 @@ define fluentd::plugin (
}
}
'file': {
# parameter validation
if ! ($ensure in [ 'present', 'absent' ]) {
fail('ensure parameter must be present or absent')
}
validate_string($source)
fluentd::plugin::file { $name:

View File

@@ -1,11 +1,14 @@
# Configure package repository
#
class fluentd::repo inherits fluentd {
if $::fluentd::manage_repo {
if $::fluentd::repo_manage {
case $::osfamily {
'Debian': {
include ::fluentd::repo::apt
}
'RedHat': {
include ::fluentd::repo::yum
}
default: {
fail("No repo available for ${::osfamily}/${::operatingsystem}")
}

View File

@@ -2,12 +2,17 @@
#
class fluentd::repo::apt (
$ensure = 'present',
$location = downcase("http://packages.treasuredata.com/2/${::operatingsystem}/${::lsbdistcodename}"),
$location = downcase("http://packages.treasuredata.com/2/${::lsbdistid}/${::lsbdistcodename}"),
$release = $::lsbdistcodename,
$repos = 'contrib',
$architecture = $::architecture,
$key = {
'id' => 'C901622B5EC4AF820C38AB861093DB45A12E206F',
'source' => 'https://packages.treasuredata.com/GPG-KEY-td-agent'
'id' => 'BEE682289B2217F45AF4CC3F901F9177AB97ACBE',
'source' => 'http://packages.treasuredata.com/GPG-KEY-td-agent'
},
$include = {
'src' => false,
'deb' => true,
},
) {
@@ -17,7 +22,9 @@ class fluentd::repo::apt (
ensure => $ensure,
location => $location,
release => $release,
architecture => $architecture,
repos => $repos,
key => $key,
include => $include,
}
}

34
manifests/repo/yum.pp Normal file
View File

@@ -0,0 +1,34 @@
# Configure yumrepo
#
class fluentd::repo::yum (
$ensure = 'present',
$descr = 'TreasureData',
$baseurl = 'https://packages.treasuredata.com/2/redhat/$releasever/$basearch',
$enabled = '1',
$gpgcheck = '1',
$gpgkey = 'https://packages.treasuredata.com/GPG-KEY-td-agent',
) {
yumrepo { 'treasure-data':
ensure => $ensure,
descr => $descr,
baseurl => $baseurl,
enabled => $enabled,
gpgcheck => $gpgcheck,
notify => Exec['add GPG key'],
}
exec { 'add GPG key':
command => "rpm --import ${fluentd::repo::yum::gpgkey}",
path => '/bin:/usr/bin/',
refreshonly => true,
}
exec { 'remove old GPG key':
command => 'rpm -e --allmatches gpg-pubkey-a12e206f-*',
path => '/bin:/usr/bin/',
onlyif => 'rpm -qi gpg-pubkey-a12e206f-*',
notify => Exec['add GPG key'],
}
}

13
manifests/user.pp Normal file
View 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'],
}
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "wywygmbh-fluentd",
"version": "0.3.0",
"version": "0.5.5",
"author": "wywy GmbH",
"summary": "Generic module for fluentd (td-agent).",
"license": "Apache-2.0",
@@ -12,6 +12,14 @@
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [ "14.04", "12.04" ]
},
{
"operatingsystem": "Debian",
"operatingsystemrelease": [ "6", "7", "8"]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [ "6", "7" ]
}
],
"dependencies": [

View File

@@ -0,0 +1,45 @@
require 'spec_helper_acceptance'
RSpec.describe 'fluentd' do
it 'runs successfully' do
manifest = File.read(File.expand_path('../../examples/test.pp', File.dirname(__FILE__)))
# Run it twice and test for idempotency
apply_manifest(manifest, catch_failures: true)
expect(apply_manifest(manifest, catch_failures: true).exit_code).to be_zero
end
# test package
describe package('td-agent') do
it { is_expected.to be_installed }
end
# test service
describe service('td-agent') do
it { is_expected.to be_running }
# @todo
# there seems to be a bug serverspec while checking if the service is enabled
# on Debian 8:
# server spec checks:
# /bin/sh -c systemctl\ --quiet\ is-enabled\ td-agent
# Failed to get unit file state for td-agent.service: No such file or directory
#
# but all update-rc.d files are present:
# /etc/rc0.d/K01td-agent
# /etc/rc1.d/K01td-agent
# /etc/rc2.d/S01td-agent
# /etc/rc3.d/S01td-agent
# /etc/rc4.d/S01td-agent
# /etc/rc5.d/S01td-agent
# /etc/rc6.d/K01td-agent
if ! ( os[:family] == 'debian' and os[:release].to_f >= 8.0 )
it { is_expected.to be_enabled }
end
end
# test gem installed plugin
describe command('/opt/td-agent/embedded/bin/gem list') do
its(:stdout) { should contain('fluent-plugin-elasticsearch') }
end
end

View File

@@ -0,0 +1,10 @@
HOSTS:
centos-66-x64:
roles:
- master
platform: el-6-x86_64
box: puppetlabs/centos-6.6-64-nocm
hypervisor: vagrant
CONFIG:
log_level: info
type: foss

View File

@@ -0,0 +1,10 @@
HOSTS:
centos-70-x64:
roles:
- master
platform: el-7-x86_64
box: puppetlabs/centos-7.0-64-nocm
hypervisor: vagrant
CONFIG:
log_level: info
type: foss

View File

@@ -0,0 +1,10 @@
HOSTS:
debian-60-x64:
roles:
- master
platform: debian-6-amd64
box: puppetlabs/debian-6.0.10-64-nocm
hypervisor: vagrant
CONFIG:
log_level: info
type: foss

View File

@@ -0,0 +1,10 @@
HOSTS:
debian-78-x64:
roles:
- master
platform: debian-7-amd64
box: puppetlabs/debian-7.8-64-nocm
hypervisor: vagrant
CONFIG:
log_level: info
type: foss

View File

@@ -0,0 +1,10 @@
HOSTS:
debian-82-x64:
roles:
- master
platform: debian-8-amd64
box: puppetlabs/debian-8.2-64-nocm
hypervisor: vagrant
CONFIG:
log_level: info
type: foss

View File

@@ -0,0 +1,10 @@
HOSTS:
ubuntu-server-1204-x64:
roles:
- master
platform: ubuntu-12.04-amd64
box: puppetlabs/ubuntu-12.04-64-nocm
hypervisor: vagrant
CONFIG:
log_level: info
type: foss

View File

@@ -0,0 +1,10 @@
HOSTS:
ubuntu-server-1404-x64:
roles:
- master
platform: ubuntu-14.04-amd64
box: puppetlabs/ubuntu-14.04-64-nocm
hypervisor: vagrant
CONFIG:
log_level: info
type: foss

View File

@@ -1,16 +1,7 @@
require 'spec_helper'
describe 'fluentd::config', :type => :class do
let(:facts) {
{
:osfamily => 'Debian',
:lsbdistid => 'Ubuntu',
:operatingsystem => 'Ubuntu',
:lsbdistcodename => 'precise',
}
}
describe 'when called with no parameters on Ubuntu' do
shared_examples 'when called with no parameters' do
it {
should contain_file('/etc/td-agent/td-agent.conf').with({
'ensure' => 'file',
@@ -28,4 +19,28 @@ describe 'fluentd::config', :type => :class do
})
}
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

View File

@@ -1,16 +1,8 @@
require 'spec_helper'
describe 'fluentd::install', :type => :class do
let(:facts) {
{
:osfamily => 'Debian',
:lsbdistid => 'Ubuntu',
:operatingsystem => 'Ubuntu',
:lsbdistcodename => 'precise',
}
}
describe 'when called with no parameters on Ubuntu' do
shared_examples 'when called with no parameters' do
it {
should contain_package('fluentd').with({
'ensure' => 'installed',
@@ -19,4 +11,28 @@ describe 'fluentd::install', :type => :class do
})
}
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

View File

@@ -7,6 +7,7 @@ describe 'fluentd::repo::apt', :type => :class do
:lsbdistid => 'Ubuntu',
:operatingsystem => 'Ubuntu',
:lsbdistcodename => 'precise',
:architecture => 'amd64',
}
}
@@ -18,9 +19,14 @@ describe 'fluentd::repo::apt', :type => :class do
'location' => 'http://packages.treasuredata.com/2/ubuntu/precise',
'release' => 'precise',
'repos' => 'contrib',
'architecture' => 'amd64',
'key' => {
'id' => 'C901622B5EC4AF820C38AB861093DB45A12E206F',
'source' => 'https://packages.treasuredata.com/GPG-KEY-td-agent'
'id' => 'BEE682289B2217F45AF4CC3F901F9177AB97ACBE',
'source' => 'http://packages.treasuredata.com/GPG-KEY-td-agent'
},
'include' => {
'src' => false,
'deb' => true
}
})
}

View File

@@ -1,18 +1,30 @@
require 'spec_helper'
describe 'fluentd::repo', :type => :class do
context 'when called with no parameters on osfamily Debian' do
let(:facts) {
{
:osfamily => 'Debian',
:lsbdistid => 'Ubuntu',
:operatingsystem => 'Ubuntu',
:lsbdistcodename => 'precise',
:architecture => 'amd64',
}
}
describe 'when called with no parameters on Ubuntu' do
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

View File

@@ -0,0 +1,27 @@
require 'spec_helper'
describe 'fluentd::repo::yum', :type => :class do
let(:facts) {
{
:osfamily => 'RedHat',
}
}
describe 'when called with no parameters on RedHat' do
it {
should contain_yumrepo('treasure-data').with({
'ensure' => 'present',
'baseurl' => 'https://packages.treasuredata.com/2/redhat/$releasever/$basearch',
'descr' => 'TreasureData',
'enabled' => '1',
'gpgcheck' => '1'
}).that_notifies('Exec[add GPG key]')
should contain_exec('add GPG key').with({
'command' => 'rpm --import https://packages.treasuredata.com/GPG-KEY-td-agent',
'path' => '/bin:/usr/bin/',
'refreshonly' => 'true'
})
}
end
end

View File

@@ -1,16 +1,7 @@
require 'spec_helper'
describe 'fluentd::config', :type => :class do
let(:facts) {
{
:osfamily => 'Debian',
:lsbdistid => 'Ubuntu',
:operatingsystem => 'Ubuntu',
:lsbdistcodename => 'precise',
}
}
describe 'when called with no parameters on Ubuntu' do
shared_examples 'when called with no parameters' do
it {
should contain_service('fluentd').with({
'name' => 'td-agent',
@@ -21,4 +12,28 @@ describe 'fluentd::config', :type => :class do
})
}
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

View File

@@ -1,16 +1,7 @@
require 'spec_helper'
describe 'fluentd', :type => :class do
let(:facts) {
{
:osfamily => 'Debian',
:lsbdistid => 'Ubuntu',
:operatingsystem => 'Ubuntu',
:lsbdistcodename => 'precise',
}
}
describe 'when called with no parameters on Ubuntu' do
shared_examples 'when called with no parameters' do
it {
should contain_class('fluentd::repo')
should contain_class('fluentd::install')
@@ -18,4 +9,29 @@ describe 'fluentd', :type => :class do
should contain_class('fluentd::service')
}
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

View File

@@ -0,0 +1,37 @@
require 'spec_helper'
describe 'fluentd::user', :type => :class do
shared_examples 'when called with no parameters' do
it {
should contain_user('fluentd').with({
'name' => 'td-agent',
'gid' => 'td-agent',
'groups' => ['adm']
})
}
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

View File

@@ -7,6 +7,7 @@ describe 'fluentd::filter' do
:lsbdistid => 'Ubuntu',
:operatingsystem => 'Ubuntu',
:lsbdistcodename => 'precise',
:architecture => 'amd64',
}
}
let(:pre_condition) { 'include fluentd' }

View File

@@ -7,6 +7,7 @@ describe 'fluentd::match' do
:lsbdistid => 'Ubuntu',
:operatingsystem => 'Ubuntu',
:lsbdistcodename => 'precise',
:architecture => 'amd64',
}
}
let(:pre_condition) { 'include fluentd' }
@@ -24,9 +25,11 @@ describe 'fluentd::match' do
'shared_key' => 'my_shared_key',
'self_hostname' => 'instance.test.com',
'ca_cert_path' => '/path/to/ca.cert',
'servers' => {
'host' => 'test.server.com'
'server' => [
{
'host' => 'test.server.com',
}
]
}
}
end
@@ -40,9 +43,51 @@ describe 'fluentd::match' do
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(/<servers>/).
with_content(/<server>/).
with_content(/host test.server.com/).
with_content(/<\/servers>/).
with_content(/<\/server>/).
with_content(/<\/match>/)
end
end
context 'multiple store' do
let(:title) { 'test' }
let(:params) do
{
priority: '30',
pattern: '*.test',
config: {
'type' => 'copy',
'store' => [
{
'type' => 'elasticsearch',
'logstashformat' => true,
'hosts' => '172.20.10.17:9200',
'flush_interval' => '30s',
},
{
'type' => 'file',
'path' => '/tmp/td-agent-debug.log',
}
]
}
}
end
it do
is_expected.to contain_file('/etc/td-agent/conf.d/30-match-test.conf').
with_content(/<match \*.test>/).
with_content(/type copy/).
with_content(/<store>/).
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

View File

@@ -7,6 +7,7 @@ describe 'fluentd::plugin' do
:lsbdistid => 'Ubuntu',
:operatingsystem => 'Ubuntu',
:lsbdistcodename => 'precise',
:architecture => 'amd64',
}
}
let(:pre_condition) { 'include fluentd' }

View File

@@ -7,6 +7,7 @@ describe 'fluentd::source' do
:lsbdistid => 'Ubuntu',
:operatingsystem => 'Ubuntu',
:lsbdistcodename => 'precise',
:architecture => 'amd64',
}
}
let(:pre_condition) { 'include fluentd' }

View File

@@ -0,0 +1,22 @@
require 'beaker-rspec'
require 'beaker/puppet_install_helper'
run_puppet_install_helper unless ENV['BEAKER_provision'] == 'no'
RSpec.configure do |c|
# Project root
module_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
# Readable test descriptions
c.formatter = :documentation
# Configure all nodes in nodeset
c.before :suite do
# Install module
puppet_module_install(:source => module_root, :module_name => 'fluentd')
hosts.each do |host|
on host, puppet('module', 'install', 'puppetlabs-stdlib', '--version', '4.6.0')
on host, puppet('module', 'install', 'puppetlabs-apt', '--version', '2.0.0')
end
end
end

View File

@@ -2,8 +2,8 @@
<% @config.each do |key, val| -%>
<%- if val.is_a?( Hash ) -%>
<<%= key -%>>
<%- val.each do |key, val| -%>
<%= key -%> <%= val %>
<%- val.each do |key2, val2| -%>
<%= key2 -%> <%= val2 %>
<%- end -%>
</<%= key %>>
<%- else -%>

View File

@@ -6,6 +6,32 @@
<%= key -%> <%= val %>
<%- end -%>
</<%= key %>>
<%- elsif val.is_a?( Array ) -%>
<%- val.each do |k, v| -%>
<<%= key -%>>
<%- if k.is_a?( Hash ) -%>
<%- k.each do |x, y| -%>
<%- if y.is_a?( Array ) -%>
<%- y.each do |a, b| -%>
<<%= x -%>>
<%- if a.is_a?( Hash ) -%>
<%- a.each do |c, d| -%>
<%= c -%> <%= d %>
<%- end -%>
<%- else -%>
<%= a -%> <%= b %>
<%- end -%>
</<%= x %>>
<%- end -%>
<%- else -%>
<%= x -%> <%= y %>
<%- end -%>
<%- end -%>
<%- else -%>
<%= k -%> <%= v %>
<%- end -%>
</<%= key %>>
<%- end -%>
<%- else -%>
<%= key -%> <%= val %>
<%- end -%>