mirror of
https://github.com/krislamo/puppet-fluentd
synced 2025-09-13 08:59:29 +00:00
Compare commits
44 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
bb2346df50 | ||
|
e062d4f2e0 | ||
|
f32ea2c0ba | ||
|
8081e8df20 | ||
|
6cb1364023 | ||
|
3dab36ee83 | ||
|
8916d18654 | ||
|
75a537432c | ||
|
9754e64490 | ||
|
6b915de23c | ||
|
3797e70098 | ||
|
9c34a6cbf6 | ||
|
9f79619a08 | ||
|
89287cc828 | ||
|
3e36e94971 | ||
|
ae7256a8c2 | ||
|
be1a555591 | ||
|
3ef403cf65 | ||
|
9900e8f172 | ||
|
7ddbe46025 | ||
|
e3e4b9bd61 | ||
|
9aaccda9e0 | ||
|
2b86e57b7b | ||
|
b0000fc99b | ||
|
08a27245f7 | ||
|
4c3f1f9a18 | ||
|
c39f88be0b | ||
|
b465108fcc | ||
|
567a07ebb2 | ||
|
a6fbde8a4c | ||
|
471eb1bbf2 | ||
|
9eb93da056 | ||
|
afc59cb27e | ||
|
490868d6b1 | ||
|
57740bc18d | ||
|
e693af3c42 | ||
|
2e5892663e | ||
|
5da076c98a | ||
|
c6e3a69f2b | ||
|
d11007eb35 | ||
|
7beb6b5298 | ||
|
7821317f84 | ||
|
6a08c099c4 | ||
|
88f021de43 |
22
CHANGELOG.md
22
CHANGELOG.md
@@ -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
|
||||
|
3
Gemfile
3
Gemfile
@@ -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
122
README.md
@@ -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
|
||||
|
1
Rakefile
1
Rakefile
@@ -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"
|
||||
|
@@ -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',
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@@ -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
10
examples/test.pp
Normal 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']
|
||||
}
|
@@ -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
|
||||
|
||||
|
@@ -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'],
|
||||
}
|
||||
|
@@ -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']
|
||||
}
|
||||
|
@@ -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'
|
||||
# }
|
||||
# }]
|
||||
# }
|
||||
# }
|
||||
#
|
||||
|
@@ -13,19 +13,17 @@ class fluentd::params {
|
||||
$conf_dir = "${config_path}/conf.d"
|
||||
$config_file = "${config_path}/td-agent.conf"
|
||||
# user params
|
||||
$user_name = 'td-agent'
|
||||
$user_group = 'td-agent'
|
||||
$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}")
|
||||
|
@@ -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:
|
||||
|
@@ -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}")
|
||||
}
|
||||
|
@@ -1,23 +1,30 @@
|
||||
# Configure apt::source
|
||||
#
|
||||
class fluentd::repo::apt (
|
||||
$ensure = 'present',
|
||||
$location = downcase("http://packages.treasuredata.com/2/${::operatingsystem}/${::lsbdistcodename}"),
|
||||
$release = $::lsbdistcodename,
|
||||
$repos = 'contrib',
|
||||
$key = {
|
||||
$ensure = 'present',
|
||||
$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,
|
||||
},
|
||||
) {
|
||||
|
||||
include '::apt'
|
||||
|
||||
apt::source { 'treasure-data':
|
||||
ensure => $ensure,
|
||||
location => $location,
|
||||
release => $release,
|
||||
repos => $repos,
|
||||
key => $key,
|
||||
ensure => $ensure,
|
||||
location => $location,
|
||||
release => $release,
|
||||
architecture => $architecture,
|
||||
repos => $repos,
|
||||
key => $key,
|
||||
include => $include,
|
||||
}
|
||||
}
|
||||
|
26
manifests/repo/yum.pp
Normal file
26
manifests/repo/yum.pp
Normal 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
13
manifests/user.pp
Normal 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'],
|
||||
}
|
||||
}
|
||||
}
|
@@ -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": [
|
||||
|
45
spec/acceptance/fluentd_spec.rb
Normal file
45
spec/acceptance/fluentd_spec.rb
Normal 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
|
10
spec/acceptance/nodesets/centos-66-x64.yml
Normal file
10
spec/acceptance/nodesets/centos-66-x64.yml
Normal 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
|
10
spec/acceptance/nodesets/centos-70-x64.yml
Normal file
10
spec/acceptance/nodesets/centos-70-x64.yml
Normal 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
|
10
spec/acceptance/nodesets/debian-60-x64.yml
Normal file
10
spec/acceptance/nodesets/debian-60-x64.yml
Normal 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
|
10
spec/acceptance/nodesets/debian-78-x64.yml
Normal file
10
spec/acceptance/nodesets/debian-78-x64.yml
Normal 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
|
10
spec/acceptance/nodesets/debian-82-x64.yml
Normal file
10
spec/acceptance/nodesets/debian-82-x64.yml
Normal 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
|
10
spec/acceptance/nodesets/ubuntu-server-1204-x64.yml
Normal file
10
spec/acceptance/nodesets/ubuntu-server-1204-x64.yml
Normal 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
|
10
spec/acceptance/nodesets/ubuntu-server-1404-x64.yml
Normal file
10
spec/acceptance/nodesets/ubuntu-server-1404-x64.yml
Normal 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
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -7,6 +7,7 @@ describe 'fluentd::repo::apt', :type => :class do
|
||||
:lsbdistid => 'Ubuntu',
|
||||
:operatingsystem => 'Ubuntu',
|
||||
:lsbdistcodename => 'precise',
|
||||
:architecture => 'amd64',
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,13 +15,18 @@ describe 'fluentd::repo::apt', :type => :class do
|
||||
it {
|
||||
should contain_class('apt')
|
||||
should contain_apt__source('treasure-data').with({
|
||||
'ensure' => 'present',
|
||||
'location' => 'http://packages.treasuredata.com/2/ubuntu/precise',
|
||||
'release' => 'precise',
|
||||
'repos' => 'contrib',
|
||||
'key' => {
|
||||
'ensure' => 'present',
|
||||
'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
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@@ -1,18 +1,30 @@
|
||||
require 'spec_helper'
|
||||
|
||||
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',
|
||||
:architecture => 'amd64',
|
||||
}
|
||||
}
|
||||
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
|
||||
|
27
spec/classes/fluentd_repo_yum_spec.rb
Normal file
27
spec/classes/fluentd_repo_yum_spec.rb
Normal 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
|
@@ -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
|
||||
|
@@ -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
|
||||
|
37
spec/classes/fluentd_user_spec.rb
Normal file
37
spec/classes/fluentd_user_spec.rb
Normal 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
|
@@ -7,6 +7,7 @@ describe 'fluentd::filter' do
|
||||
:lsbdistid => 'Ubuntu',
|
||||
:operatingsystem => 'Ubuntu',
|
||||
:lsbdistcodename => 'precise',
|
||||
:architecture => 'amd64',
|
||||
}
|
||||
}
|
||||
let(:pre_condition) { 'include fluentd' }
|
||||
|
@@ -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,10 +43,52 @@ 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
|
||||
end
|
@@ -7,6 +7,7 @@ describe 'fluentd::plugin' do
|
||||
:lsbdistid => 'Ubuntu',
|
||||
:operatingsystem => 'Ubuntu',
|
||||
:lsbdistcodename => 'precise',
|
||||
:architecture => 'amd64',
|
||||
}
|
||||
}
|
||||
let(:pre_condition) { 'include fluentd' }
|
||||
|
@@ -7,6 +7,7 @@ describe 'fluentd::source' do
|
||||
:lsbdistid => 'Ubuntu',
|
||||
:operatingsystem => 'Ubuntu',
|
||||
:lsbdistcodename => 'precise',
|
||||
:architecture => 'amd64',
|
||||
}
|
||||
}
|
||||
let(:pre_condition) { 'include fluentd' }
|
||||
|
22
spec/spec_helper_acceptance.rb
Normal file
22
spec/spec_helper_acceptance.rb
Normal 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
|
@@ -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 -%>
|
||||
|
Reference in New Issue
Block a user