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

41 Commits
0.1.0 ... 0.5.0

Author SHA1 Message Date
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
Jan Krause
b5d8088d31 prepare 0.3.0 release 2015-12-09 16:06:00 +01:00
Jan Krause
31a92b59eb pin dependency modules in fixtures
also increases apt dependency
2015-12-09 16:04:47 +01:00
Jan Krause
641873546f minor changes 2015-12-09 16:04:28 +01:00
Jan Krause
a08cd1f4f4 change travis build notification 2015-12-09 14:24:28 +01:00
Max Wilhelm
428a220e1f increased stdlib dependency 2015-12-08 11:50:23 +01:00
Max Wilhelm
5a67bcac9a added version badge to README.md 2015-12-07 18:51:12 +01:00
40 changed files with 705 additions and 114 deletions

View File

@@ -1,6 +1,10 @@
fixtures: fixtures:
repositories: repositories:
apt: "https://github.com/puppetlabs/puppetlabs-apt.git" apt:
stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git" repo: "https://github.com/puppetlabs/puppetlabs-apt.git"
ref: "2.0.0"
stdlib:
repo: "https://github.com/puppetlabs/puppetlabs-stdlib.git"
ref: "4.6.0"
symlinks: symlinks:
fluentd: "#{source_dir}" fluentd: "#{source_dir}"

View File

@@ -1,8 +1,8 @@
---
sudo: false sudo: false
language: ruby language: ruby
bundler_args: --without system_tests bundler_args: --without system_tests
script: "bundle exec rake validate && bundle exec rake lint && bundle exec rake spec SPEC_OPTS='--format documentation'" script: bundle exec rake validate && bundle exec rake lint && bundle exec rake spec
SPEC_OPTS='--format documentation'
matrix: matrix:
fast_finish: true fast_finish: true
include: include:
@@ -13,4 +13,5 @@ matrix:
- rvm: 2.1.6 - rvm: 2.1.6
env: PUPPET_GEM_VERSION="~> 4.0" STRICT_VARIABLES="yes" env: PUPPET_GEM_VERSION="~> 4.0" STRICT_VARIABLES="yes"
notifications: notifications:
email: max.wilhelm@wywy.com 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,28 @@
# Changelog # Changelog
## 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
* Module pinning on rspec tests
* Minor changes
## 0.2.0
* Increased stdlib dependency
## 0.1.0 ## 0.1.0
Initial release * Initial release

View File

@@ -5,3 +5,6 @@ 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-rspec'
gem 'beaker-puppet_install_helper'
gem 'metadata-json-lint'

122
README.md
View File

@@ -1,16 +1,21 @@
# wywygmbh/fluentd Puppet Module # wywygmbh/fluentd Puppet Module
[![GitHub version](https://badge.fury.io/gh/wywygmbh%2Fpuppet-fluentd.svg)](https://github.com/wywygmbh/puppet-fluentd)
[![Build Status](https://travis-ci.org/wywygmbh/puppet-fluentd.svg?branch=master)](https://travis-ci.org/wywygmbh/puppet-fluentd) [![Build Status](https://travis-ci.org/wywygmbh/puppet-fluentd.svg?branch=master)](https://travis-ci.org/wywygmbh/puppet-fluentd)
#### Table of Contents #### Table of Contents
1. [Description](#description) 1. [Description](#description)
1. [Setup - The basics of getting started with fluentd](#setup) 1. [Setup - The basics of getting started with fluentd](#setup)
1. [Usage](#usage) 1. [Usage](#usage)
* [Configuration](#configuration) * [Configuration](#configuration)
* [Parameters](#parameters)
* [Source](#source) * [Source](#source)
* [Filter](#filter) * [Filter](#filter)
* [Match](#match) * [Match](#match)
* [Match Store](#match-store)
* [Plugin Installation](#plugin-installation) * [Plugin Installation](#plugin-installation)
* [Requirements](#requirements) * [Requirements](#requirements)
1. [Limitations - OS compatibility, etc.](#limitations) 1. [Limitations - OS compatibility, etc.](#limitations)
@@ -37,6 +42,67 @@ include '::fluentd'
### Configuration ### 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_enabled`
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 #### Source
```puppet ```puppet
::fluentd::source { 'test': ::fluentd::source { 'test':
@@ -94,9 +160,9 @@ include '::fluentd'
'shared_key' => 'my_shared_key', 'shared_key' => 'my_shared_key',
'self_hostname' => 'instance.test.com', 'self_hostname' => 'instance.test.com',
'ca_cert_path' => '/path/to/ca.cert', 'ca_cert_path' => '/path/to/ca.cert',
'servers' => { 'server' => [{
'host' => 'test.server.com' 'host' => 'test.server.com',
} }]
} }
} }
``` ```
@@ -110,9 +176,48 @@ include '::fluentd'
shared_key my_shared_key shared_key my_shared_key
self_hostname instance.test.com self_hostname instance.test.com
ca_cert_path /path/to/ca.cert ca_cert_path /path/to/ca.cert
<servers> <server>
host test.server.com 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> </match>
``` ```
@@ -159,6 +264,13 @@ 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=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 ## License

View File

@@ -9,8 +9,27 @@
'shared_key' => 'my_shared_key', 'shared_key' => 'my_shared_key',
'self_hostname' => 'instance.test.com', 'self_hostname' => 'instance.test.com',
'ca_cert_path' => '/path/to/ca.cert', 'ca_cert_path' => '/path/to/ca.cert',
'servers' => { 'server' => [{
'host' => 'test.server.com' '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',
}
]
} }
} }

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 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 source is not present at all, the gem will be installed from the default gem
repositories." repositories."
confine :exists => "/opt/td-agent/embedded/bin/gem"
has_feature :versionable, :install_options has_feature :versionable, :install_options

View File

@@ -1,4 +1,4 @@
# Configure package # Configure config files/directories
# #
class fluentd::config inherits fluentd { class fluentd::config inherits fluentd {
@@ -16,5 +16,4 @@ class fluentd::config inherits fluentd {
group => $::fluentd::user_group, group => $::fluentd::user_group,
mode => '0750', mode => '0750',
} }
} }

View File

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

View File

@@ -5,7 +5,7 @@
# #
# Parameters # Parameters
# ---------- # ----------
# [*manage_repo*] # [*repo_manage*]
# 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*]
@@ -27,7 +27,19 @@
# Service ensure # Service ensure
# Default: 'running' # Default: 'running'
# [*service_enabled*] # [*service_enabled*]
# Defines if the service should be enabled, defaults to 'true' # Defines if the service should be enabled
# Default: 'true'
# [*user_manage*]
# Defines if the user should be manage, which will add the user
# to groups defined in $user_groups.
# For example to be able to view the /var/log directory with group adm
# Default: 'true'
# [*user_name*]
# Default: 'td-agent'
# [*user_group*]
# Default: 'td-agent'
# [*user_groups*]
# Default: '["adm"]'
# #
# Examples # Examples
# -------- # --------
@@ -41,7 +53,7 @@
# Copyright 2015 wywy GmbH, unless otherwise noted. # Copyright 2015 wywy GmbH, unless otherwise noted.
# #
class fluentd ( class fluentd (
$manage_repo = $::fluentd::params::manage_repo, $repo_manage = $::fluentd::params::repo_manage,
$package_ensure = $::fluentd::params::package_ensure, $package_ensure = $::fluentd::params::package_ensure,
$package_name = $::fluentd::params::package_name, $package_name = $::fluentd::params::package_name,
$package_install_options = $::fluentd::params::package_install_options, $package_install_options = $::fluentd::params::package_install_options,
@@ -52,18 +64,21 @@ class fluentd (
$config_path = $::fluentd::params::config_path, $config_path = $::fluentd::params::config_path,
$conf_dir = $::fluentd::params::conf_dir, $conf_dir = $::fluentd::params::conf_dir,
$config_file = $::fluentd::params::config_file, $config_file = $::fluentd::params::config_file,
$user_manage = $::fluentd::params::user_manage,
$user_name = $::fluentd::params::user_name, $user_name = $::fluentd::params::user_name,
$user_group = $::fluentd::params::user_group, $user_group = $::fluentd::params::user_group,
$user_groups = $::fluentd::params::user_groups,
) inherits fluentd::params { ) inherits fluentd::params {
# parameter validation # parameter validation
validate_bool($manage_repo) validate_bool($repo_manage)
validate_string($package_ensure) validate_string($package_ensure)
validate_string($package_name) validate_string($package_name)
validate_array($package_install_options) validate_array($package_install_options)
validate_bool($service_manage) validate_bool($service_manage)
validate_string($service_name) validate_string($service_name)
validate_bool($service_enable) validate_bool($service_enable)
if ! ($service_ensure in [ 'running', 'stopped' ]) { if ! ($service_ensure in [ 'running', 'stopped' ]) {
fail('service_ensure parameter must be running or stopped') fail('service_ensure parameter must be running or stopped')
} }
@@ -71,13 +86,14 @@ class fluentd (
# class calls # class calls
include '::fluentd::repo' include '::fluentd::repo'
include '::fluentd::install' include '::fluentd::install'
include '::fluentd::user'
include '::fluentd::config' include '::fluentd::config'
include '::fluentd::service' include '::fluentd::service'
# dependencies # dependencies
Class['::Fluentd::Repo'] -> Class['::Fluentd::Repo'] ->
Class['::Fluentd::Install'] -> Class['::Fluentd::Install'] ->
Class['::Fluentd::User'] ->
Class['::Fluentd::Config'] -> Class['::Fluentd::Config'] ->
Class['::Fluentd::Service'] Class['::Fluentd::Service']
} }

View File

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

View File

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

View File

@@ -40,7 +40,7 @@ define fluentd::plugin (
'gem': { 'gem': {
fluentd::plugin::gem { $name: fluentd::plugin::gem { $name:
ensure => $ensure, ensure => $ensure,
require => Class['Fluentd::Install'] require => Class['Fluentd::Install'],
} }
} }
'file': { 'file': {
@@ -49,7 +49,7 @@ define fluentd::plugin (
fluentd::plugin::file { $name: fluentd::plugin::file { $name:
ensure => $ensure, ensure => $ensure,
source => $source, source => $source,
require => Class['Fluentd::Install'] require => Class['Fluentd::Install'],
} }
} }
default: { default: {

View File

@@ -11,6 +11,6 @@ define fluentd::plugin::gem (
package { $name: package { $name:
ensure => $ensure, ensure => $ensure,
provider => 'fluentd_gem', provider => 'fluentd_gem',
notify => Class['Fluentd::Service'] notify => Class['Fluentd::Service'],
} }
} }

View File

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

View File

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

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

@@ -0,0 +1,26 @@
# 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,
}
}

View File

@@ -1,4 +1,4 @@
# Configure package # Configure service
# #
class fluentd::service inherits fluentd { class fluentd::service inherits fluentd {

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", "name": "wywygmbh-fluentd",
"version": "0.1.0", "version": "0.5.0",
"author": "wywy GmbH", "author": "wywy GmbH",
"summary": "Generic module for fluentd (td-agent).", "summary": "Generic module for fluentd (td-agent).",
"license": "Apache-2.0", "license": "Apache-2.0",
@@ -12,11 +12,19 @@
{ {
"operatingsystem": "Ubuntu", "operatingsystem": "Ubuntu",
"operatingsystemrelease": [ "14.04", "12.04" ] "operatingsystemrelease": [ "14.04", "12.04" ]
},
{
"operatingsystem": "Debian",
"operatingsystemrelease": [ "6", "7", "8"]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [ "6", "7" ]
} }
], ],
"dependencies": [ "dependencies": [
{ "name":"puppetlabs-stdlib","version_requirement":">= 1.0.0" }, { "name": "puppetlabs/stdlib", "version_requirement": ">= 4.6.0 < 5.0.0" },
{ "name": "puppetlabs/apt", "version_requirement": ">= 1.8.0 < 3.0.0" } { "name": "puppetlabs/apt", "version_requirement": ">= 2.0.0 < 3.0.0" }
], ],
"data_provider": null "data_provider": null
} }

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

View File

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

View File

@@ -7,6 +7,7 @@ describe 'fluentd::repo::apt', :type => :class do
:lsbdistid => 'Ubuntu', :lsbdistid => 'Ubuntu',
:operatingsystem => 'Ubuntu', :operatingsystem => 'Ubuntu',
:lsbdistcodename => 'precise', :lsbdistcodename => 'precise',
:architecture => 'amd64',
} }
} }
@@ -14,13 +15,18 @@ describe 'fluentd::repo::apt', :type => :class do
it { it {
should contain_class('apt') should contain_class('apt')
should contain_apt__source('treasure-data').with({ should contain_apt__source('treasure-data').with({
'ensure' => 'present', 'ensure' => 'present',
'location' => 'http://packages.treasuredata.com/2/ubuntu/precise', 'location' => 'http://packages.treasuredata.com/2/ubuntu/precise',
'release' => 'precise', 'release' => 'precise',
'repos' => 'contrib', 'repos' => 'contrib',
'key' => { 'architecture' => 'amd64',
'key' => {
'id' => 'C901622B5EC4AF820C38AB861093DB45A12E206F', 'id' => 'C901622B5EC4AF820C38AB861093DB45A12E206F',
'source' => 'https://packages.treasuredata.com/GPG-KEY-td-agent' 'source' => 'http://packages.treasuredata.com/GPG-KEY-td-agent'
},
'include' => {
'src' => false,
'deb' => true
} }
}) })
} }

View File

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

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

View File

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

View File

@@ -0,0 +1,36 @@
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',
}
}
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

@@ -24,9 +24,11 @@ describe 'fluentd::match' do
'shared_key' => 'my_shared_key', 'shared_key' => 'my_shared_key',
'self_hostname' => 'instance.test.com', 'self_hostname' => 'instance.test.com',
'ca_cert_path' => '/path/to/ca.cert', 'ca_cert_path' => '/path/to/ca.cert',
'servers' => { 'server' => [
'host' => 'test.server.com' {
} 'host' => 'test.server.com',
}
]
} }
} }
end end
@@ -40,10 +42,52 @@ describe 'fluentd::match' do
with_content(/shared_key my_shared_key/). with_content(/shared_key my_shared_key/).
with_content(/self_hostname instance.test.com/). with_content(/self_hostname instance.test.com/).
with_content(/ca_cert_path \/path\/to\/ca.cert/). with_content(/ca_cert_path \/path\/to\/ca.cert/).
with_content(/<servers>/). with_content(/<server>/).
with_content(/host test.server.com/). with_content(/host test.server.com/).
with_content(/<\/servers>/). with_content(/<\/server>/).
with_content(/<\/match>/) with_content(/<\/match>/)
end end
end 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
end

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

@@ -6,6 +6,32 @@
<%= key -%> <%= val %> <%= key -%> <%= val %>
<%- end -%> <%- end -%>
</<%= key %>> </<%= 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 -%> <%- else -%>
<%= key -%> <%= val %> <%= key -%> <%= val %>
<%- end -%> <%- end -%>