mirror of
https://github.com/krislamo/puppet-fluentd
synced 2025-09-13 08:59:29 +00:00
Compare commits
54 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
fc94e7ba6f | ||
|
3fb5293880 | ||
|
e5650f47d1 | ||
|
49848b2afd | ||
|
f4c24ee881 | ||
|
2e789170a0 | ||
|
22a9578a88 | ||
|
9eb19b3d1b | ||
|
6a05cae33e | ||
|
2183f670f2 | ||
|
bcad5ca42c | ||
|
26694848cb | ||
|
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 |
16
.travis.yml
16
.travis.yml
@@ -6,12 +6,16 @@ script: bundle exec rake validate && bundle exec rake lint && bundle exec rake s
|
||||
matrix:
|
||||
fast_finish: true
|
||||
include:
|
||||
- rvm: 1.9.3
|
||||
env: PUPPET_GEM_VERSION="~> 3.0"
|
||||
- rvm: 2.1.5
|
||||
env: PUPPET_GEM_VERSION="~> 3.0"
|
||||
- rvm: 2.1.6
|
||||
env: PUPPET_GEM_VERSION="~> 4.0" STRICT_VARIABLES="yes"
|
||||
- rvm: 2.1.10
|
||||
env: PUPPET_VERSION="~> 3.0"
|
||||
- rvm: 2.1.10
|
||||
env: PUPPET_VERSION="~> 4.0" STRICT_VARIABLES="yes"
|
||||
- rvm: 2.2.7
|
||||
env: PUPPET_VERSION="~> 4.0" STRICT_VARIABLES="yes"
|
||||
- rvm: 2.3.4
|
||||
env: PUPPET_VERSION="~> 4.0" STRICT_VARIABLES="yes"
|
||||
- rvm: 2.4.1
|
||||
env: PUPPET_VERSION="~> 4.0" STRICT_VARIABLES="yes"
|
||||
notifications:
|
||||
slack:
|
||||
secure: WVBx/OJqLpX9WXyiejEdnOcAf+5ShWJ2gcyeBCX032iKzPphcdPKqH+jnlFaKjqQCZARbRqzlj/if3FZWAlhWtTrWrcY545dRHcsaGvJ/nMtdHlBUuwUNHipSn+RTXtorsYz0efhJMPye2LMl0HgAp3rEs70XUt8rZOwdedLGVgfWRwM+KixhSf8P08v9QjNRNdhWII37KFRdqv/NHryNlVKsTLH6fQOyIvok3vrTvMR8rWMRETXv6JLpCJ3FfOrxo53fW7q+GlXXuVcQ2OGlgxm3eke6q2aXZAqczeB5CSlWgUEA5T3rQ//WI3enwTayRajV/9O26HZvASjSTnDRiSSv1itYqg1Uy6kuJy5ANpBizOyWY6/QTM5Rw00AXvaY9ur0EmyNe5vLNHyTxzdr4R+rXjE07yCDvWM9RGbu+4BipP+mAoJTkuCIP54FWYn1qOJnC8DYywD/+wniCNLbp6yMgbG/aC6H5RmuSy+3xRoEbwvyXKUgA+4gL3I3aAIvidBG+yazRBFvRCn4pUJdTEc4Cpu0jhQWXWyZSE66HNPKyIOXl9JPTzul08MDo9OaqBt+K3yeMVA8EPr196mWLwerF+dExQ2PJhUu/7MAiOgFrIr4/d05iKhj4ivLYBRNN317s2NVo8qyfhPHlfv6PyzhllC/qjClQ2rLOemVhg=
|
||||
|
25
CHANGELOG.md
25
CHANGELOG.md
@@ -1,4 +1,29 @@
|
||||
# Changelog
|
||||
## 0.5.4
|
||||
* fixed templates/filter.erb
|
||||
* fixed removing of old GPG key for yum repos
|
||||
|
||||
## 0.5.3
|
||||
* update treasure data repo gpg key
|
||||
|
||||
## 0.5.2
|
||||
* Correct the docs related to the service_enable parameter
|
||||
|
||||
## 0.5.1
|
||||
* Allow to install specific version of fluent gem plugins
|
||||
|
||||
## 0.5.0
|
||||
* Added support for Debian 6, 7, 8
|
||||
* Added support for CentOS 6, 7
|
||||
* Added `::fluentd::user`, which manages the td-agent user
|
||||
* Added parameter `user_manage`
|
||||
* Added parameter `user_name`
|
||||
* Added parameter `user_group`
|
||||
* Added parameter `user_groups`
|
||||
* Added acceptance tests
|
||||
* `::fluentd::repo::apt::location default` changed to
|
||||
`http://packages.treasuredata.com/2/${::lsbdistid}/${::lsbdistcodename}`
|
||||
* Small fixes and improvements
|
||||
|
||||
## 0.4.0
|
||||
* Allows definition of multiple directives in matching rules
|
||||
|
16
Gemfile
16
Gemfile
@@ -1,7 +1,21 @@
|
||||
source 'https://rubygems.org'
|
||||
|
||||
puppetversion = ENV.key?('PUPPET_VERSION') ? "#{ENV['PUPPET_VERSION']}" : ['>= 3.3']
|
||||
ENV['PUPPET_VERSION'].nil? ? puppetversion = '~> 4.0' : puppetversion = ENV['PUPPET_VERSION'].to_s
|
||||
gem 'puppet', puppetversion
|
||||
gem 'puppetlabs_spec_helper', '>= 0.8.2'
|
||||
gem 'puppet-lint', '>= 1.0.0'
|
||||
gem 'facter', '>= 1.7.0'
|
||||
gem 'beaker-puppet_install_helper'
|
||||
gem 'metadata-json-lint'
|
||||
|
||||
beakerrspec = '> 0'
|
||||
platforms [:ruby_19, :ruby_21] do
|
||||
beakerrspec = '<= 5.6.0'
|
||||
end
|
||||
gem 'beaker-rspec', beakerrspec
|
||||
|
||||
platforms :ruby_19 do
|
||||
gem 'public_suffix', '< 1.5.0', :platforms => :ruby_19
|
||||
gem 'nokogiri', '< 1.7.0', :platforms => :ruby_19
|
||||
gem 'mime-types', '< 3.0', :platforms => :ruby_19
|
||||
end
|
74
README.md
74
README.md
@@ -11,6 +11,7 @@
|
||||
1. [Setup - The basics of getting started with fluentd](#setup)
|
||||
1. [Usage](#usage)
|
||||
* [Configuration](#configuration)
|
||||
* [Parameters](#parameters)
|
||||
* [Source](#source)
|
||||
* [Filter](#filter)
|
||||
* [Match](#match)
|
||||
@@ -41,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':
|
||||
@@ -124,7 +186,7 @@ include '::fluentd'
|
||||
::fluentd::match { 'test':
|
||||
priority => 30,
|
||||
pattern => '*.test',
|
||||
config: {
|
||||
config => {
|
||||
'type' => 'copy',
|
||||
'store' => [
|
||||
{
|
||||
@@ -166,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**
|
||||
@@ -202,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
|
||||
|
19
Rakefile
19
Rakefile
@@ -1,7 +1,22 @@
|
||||
require 'puppetlabs_spec_helper/rake_tasks'
|
||||
require 'puppet-lint/tasks/puppet-lint'
|
||||
PuppetLint.configuration.send('disable_80chars')
|
||||
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]
|
||||
|
||||
PuppetLint.configuration.log_format = '%{path}:%{line}:%{check}:%{KIND}:%{message}'
|
||||
PuppetLint.configuration.fail_on_warnings = true
|
||||
PuppetLint.configuration.send('relative')
|
||||
PuppetLint.configuration.send('disable_140chars')
|
||||
PuppetLint.configuration.send('disable_class_inherits_from_params_class')
|
||||
PuppetLint.configuration.send('disable_documentation')
|
||||
PuppetLint.configuration.send('disable_single_quote_string_with_variables')
|
||||
|
||||
exclude_paths = %w(
|
||||
pkg/**/*
|
||||
vendor/**/*
|
||||
.vendor/**/*
|
||||
spec/**/*
|
||||
)
|
||||
PuppetLint.configuration.ignore_paths = exclude_paths
|
||||
PuppetSyntax.exclude_paths = exclude_paths
|
||||
|
||||
desc "Validate manifests, templates, and ruby files"
|
||||
task :validate do
|
||||
|
@@ -5,5 +5,5 @@
|
||||
# file installation
|
||||
::fluentd::plugin { 'fluent-plugin-elasticsearch':
|
||||
type => 'file',
|
||||
source => 'puppet:///path/to/plugin'
|
||||
source => 'puppet:///modules/path/to/plugin'
|
||||
}
|
||||
|
10
examples/test.pp
Normal file
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::Config'] ->
|
||||
Class['::Fluentd::Service']
|
||||
Class['::Fluentd::Repo']
|
||||
-> Class['::Fluentd::Install']
|
||||
-> Class['::Fluentd::User']
|
||||
-> Class['::Fluentd::Config']
|
||||
-> Class['::Fluentd::Service']
|
||||
}
|
||||
|
@@ -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 = {
|
||||
'id' => 'C901622B5EC4AF820C38AB861093DB45A12E206F',
|
||||
'source' => 'https://packages.treasuredata.com/GPG-KEY-td-agent'
|
||||
$ensure = 'present',
|
||||
$location = downcase("http://packages.treasuredata.com/2/${::lsbdistid}/${::lsbdistcodename}"),
|
||||
$release = $::lsbdistcodename,
|
||||
$repos = 'contrib',
|
||||
$architecture = $::architecture,
|
||||
$key = {
|
||||
'id' => 'BEE682289B2217F45AF4CC3F901F9177AB97ACBE',
|
||||
'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,
|
||||
}
|
||||
}
|
||||
|
34
manifests/repo/yum.pp
Normal file
34
manifests/repo/yum.pp
Normal file
@@ -0,0 +1,34 @@
|
||||
# Configure yumrepo
|
||||
#
|
||||
class fluentd::repo::yum (
|
||||
$ensure = 'present',
|
||||
$descr = 'TreasureData',
|
||||
$baseurl = 'https://packages.treasuredata.com/2/redhat/$releasever/$basearch',
|
||||
$enabled = '1',
|
||||
$gpgcheck = '1',
|
||||
$gpgkey = 'https://packages.treasuredata.com/GPG-KEY-td-agent',
|
||||
) {
|
||||
|
||||
yumrepo { 'treasure-data':
|
||||
ensure => $ensure,
|
||||
descr => $descr,
|
||||
baseurl => $baseurl,
|
||||
enabled => $enabled,
|
||||
gpgcheck => $gpgcheck,
|
||||
notify => Exec['add GPG key'],
|
||||
}
|
||||
|
||||
exec { 'add GPG key':
|
||||
command => "rpm --import ${fluentd::repo::yum::gpgkey}",
|
||||
path => '/bin:/usr/bin/',
|
||||
refreshonly => true,
|
||||
}
|
||||
|
||||
exec { 'remove old GPG key':
|
||||
command => 'rpm -e --allmatches gpg-pubkey-a12e206f-*',
|
||||
path => '/bin:/usr/bin/',
|
||||
onlyif => 'rpm -qi gpg-pubkey-a12e206f-*',
|
||||
notify => Exec['add GPG key'],
|
||||
}
|
||||
|
||||
}
|
13
manifests/user.pp
Normal file
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.4.0",
|
||||
"version": "0.5.4",
|
||||
"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' => {
|
||||
'id' => 'C901622B5EC4AF820C38AB861093DB45A12E206F',
|
||||
'source' => 'https://packages.treasuredata.com/GPG-KEY-td-agent'
|
||||
'ensure' => 'present',
|
||||
'location' => 'http://packages.treasuredata.com/2/ubuntu/precise',
|
||||
'release' => 'precise',
|
||||
'repos' => 'contrib',
|
||||
'architecture' => 'amd64',
|
||||
'key' => {
|
||||
'id' => 'BEE682289B2217F45AF4CC3F901F9177AB97ACBE',
|
||||
'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' }
|
||||
|
@@ -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
|
@@ -2,8 +2,8 @@
|
||||
<% @config.each do |key, val| -%>
|
||||
<%- if val.is_a?( Hash ) -%>
|
||||
<<%= key -%>>
|
||||
<%- val.each do |key, val| -%>
|
||||
<%= key -%> <%= val %>
|
||||
<%- val.each do |key2, val2| -%>
|
||||
<%= key2 -%> <%= val2 %>
|
||||
<%- end -%>
|
||||
</<%= key %>>
|
||||
<%- else -%>
|
||||
|
Reference in New Issue
Block a user