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

44 Commits
0.3.0 ... 0.5.2

Author SHA1 Message Date
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
40 changed files with 700 additions and 107 deletions

View File

@@ -1,5 +1,27 @@
# Changelog
## 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
* Module pinning on rspec tests

View File

@@ -5,3 +5,6 @@ gem 'puppet', puppetversion
gem 'puppetlabs_spec_helper', '>= 0.8.2'
gem 'puppet-lint', '>= 1.0.0'
gem 'facter', '>= 1.7.0'
gem 'beaker-rspec'
gem 'beaker-puppet_install_helper'
gem 'metadata-json-lint'

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,6 +1,7 @@
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'
PuppetLint.configuration.send('disable_80chars')
PuppetLint.configuration.send('disable_puppet_url_without_modules')
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]
desc "Validate manifests, templates, and ruby files"

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://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

@@ -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,7 +5,7 @@
#
# Parameters
# ----------
# [*manage_repo*]
# [*repo_manage*]
# Include repository to install recent fluentd (td-agent) from
# Default: 'true'
# [*package_ensure*]
@@ -26,8 +26,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 +53,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,
@@ -52,12 +64,14 @@ class fluentd (
$config_path = $::fluentd::params::config_path,
$conf_dir = $::fluentd::params::conf_dir,
$config_file = $::fluentd::params::config_file,
$user_manage = $::fluentd::params::user_manage,
$user_name = $::fluentd::params::user_name,
$user_group = $::fluentd::params::user_group,
$user_groups = $::fluentd::params::user_groups,
) inherits fluentd::params {
# parameter validation
validate_bool($manage_repo)
validate_bool($repo_manage)
validate_string($package_ensure)
validate_string($package_name)
validate_array($package_install_options)
@@ -72,12 +86,14 @@ class fluentd (
# class calls
include '::fluentd::repo'
include '::fluentd::install'
include '::fluentd::user'
include '::fluentd::config'
include '::fluentd::service'
# dependencies
Class['::Fluentd::Repo'] ->
Class['::Fluentd::Install'] ->
Class['::Fluentd::User'] ->
Class['::Fluentd::Config'] ->
Class['::Fluentd::Service']
}

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

@@ -13,19 +13,17 @@ class fluentd::params {
$conf_dir = "${config_path}/conf.d"
$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'
'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,
}
}

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,
}
}

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.2",
"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'
'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

@@ -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 -%>