1
0
mirror of https://github.com/krislamo/puppet-fluentd synced 2025-04-16 18:04:20 +00:00

Compare commits

..

No commits in common. "master" and "0.6.0" have entirely different histories.

24 changed files with 105 additions and 235 deletions

View File

@ -6,6 +6,8 @@ script: bundle exec rake validate && bundle exec rake lint && bundle exec rake s
matrix:
fast_finish: true
include:
- 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

View File

@ -1,12 +1,4 @@
# Changelog
## 1.0.0
**Breaking changes:** This version drops puppet 3 support!
* Fix hard coded user/group names in config manifest (#23)
* migrate from stdlib validation to puppet datatypes (#24)
## 0.6.0
* Updated README
* fixed broken links, due to github organisation rename

View File

@ -1,6 +1,6 @@
source 'https://rubygems.org'
ENV['PUPPET_VERSION'].nil? ? puppetversion = '~> 4.6' : puppetversion = ENV['PUPPET_VERSION'].to_s
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'
@ -17,6 +17,6 @@ gem 'beaker-rspec', beakerrspec
platforms :ruby_19 do
gem 'public_suffix', '< 1.5.0', :platforms => :ruby_19
gem 'nokogiri', '~> 1.8.1', :platforms => :ruby_19
gem 'nokogiri', '< 1.7.0', :platforms => :ruby_19
gem 'mime-types', '< 3.0', :platforms => :ruby_19
end
end

View File

@ -1,6 +1,6 @@
# pilchkinstein-gtv/fluentd Puppet Module
# wywy/fluentd Puppet Module
[![GitHub version](https://badge.fury.io/gh/wywy%2Fpuppet-fluentd.svg)](https://github.com/pilchkinstein-gtv/puppet-fluentd)
[![GitHub version](https://badge.fury.io/gh/wywy%2Fpuppet-fluentd.svg)](https://github.com/wywy/puppet-fluentd)
[![Build Status](https://travis-ci.org/wywy/puppet-fluentd.svg?branch=master)](https://travis-ci.org/wywy/puppet-fluentd)
@ -15,7 +15,6 @@
* [Source](#source)
* [Filter](#filter)
* [Match](#match)
* [Match with buffer and chunk_keys](#match-with-buffer-and-chunk_keys)
* [Match Store](#match-store)
* [Plugin Installation](#plugin-installation)
* [Requirements](#requirements)
@ -89,7 +88,7 @@ include '::fluentd'
Path to configuration files
**Default:** '/etc/td-agent'
`config_dir`
Configuration directory name
@ -132,18 +131,7 @@ include '::fluentd'
'type' => 'tail',
'format' => 'json',
'path' => '/var/log/test-application/*.json',
'parse' => {
'type' => 'regexp',
'expression' => '^(?<name>[^ ]*) (?<user>[^ ]*) (?<age>\d*)$'
},
'storage'=> {
'type' => 'local',
'path' => 'test.pos'
},
'tag' => 'application.test',
'parse' => {
'message_format' => 'auto'
}
'tag' => 'application.test'
}
}
```
@ -154,18 +142,7 @@ include '::fluentd'
type tail
format json
path /var/log/test-application/*.json
<parse>
type regexp
expression ^(?<name>[^ ]*) (?<user>[^ ]*) (?<age>\d*)$
</parse>
<storage>
type local
path test.pos
</storage>
tag application.test
<parse>
message_format auto
</parse>
</source>
```
#### Filter
@ -224,41 +201,7 @@ include '::fluentd'
</server>
</match>
```
#### Match with buffer and chunk_keys
buffer_chunk_keys will not be included in the template. They will be filtered and only be used as a "pattern" for the buffer section.
```
::fluentd::match { 'test':
priority => 98,
pattern => 'test.**',
config => {
type => 'file',
path => '/var/log/td-agent/test/${host}',
append => true,
buffer_chunk_keys => 'host',
buffer => {
type => file,
path => /var/log/td-agent/test/buffer/,
flush_mode => immediate,
},
},
}
```
**creates:**
```
<match test.**>
type file
path /var/log/td-agent/test/${host}
append true
<buffer host>
type file
path /var/log/td-agent/test/buffer/
flush_mode immediate
</buffer>
</match>
```
#### Match Store
### Match Store
```puppet
::fluentd::match { 'test':
priority => 30,
@ -274,13 +217,7 @@ buffer_chunk_keys will not be included in the template. They will be filtered an
},
{
'type' => 'file',
'path' => '/tmp/td-agent-debug-${host}.log',
'buffer_chunk_keys' => 'host',
'buffer' => [{
'@type' => 'file',
path => '/var/log/td-agent/buffer/',
flush_mode => 'immediate',
}]
'path' => '/tmp/td-agent-debug.log',
}
]
}
@ -299,11 +236,7 @@ buffer_chunk_keys will not be included in the template. They will be filtered an
</store>
<store>
type file
path /tmp/td-agent-debug-${host}.log
<buffer host>
@type file
path /var/log/td-agent/buffer/
flush_mode immediate
path /tmp/crs
</store>
</match>
```
@ -330,14 +263,14 @@ This module gives you the possibility to install plugins as gem or files.
### Requirements
Modules:
* puppetlabs/apt >= 4.0.0
* puppetlabs/apt >= 1.8.0 < 3.0.0
## Limitations
This module has been built on and tested against Puppet 4.6 and higher.
This module has been built on and tested against Puppet 3.7.5 and higher.
The module has been tested on:
* Ubuntu 16.04
* Ubuntu 12.04
Testing on other platforms has been light and cannot be guaranteed.
@ -352,8 +285,8 @@ 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=ubuntu-server-1604-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

View File

@ -2,17 +2,9 @@
::fluentd::source { 'test':
priority => 10,
config => {
'type' => 'tail',
'format' => 'json',
'path' => '/var/log/test-application/*.json',
'parse' => {
'type' => 'regexp',
'expression' => '^(?<name>[^ ]*) (?<user>[^ ]*) (?<age>\d*)$'
},
'storage' => {
'type' => 'local',
'path' => 'test.pos'
},
'tag' => 'application.test'
'type' => 'tail',
'format' => 'json',
'path' => '/var/log/test-application/*.json',
'tag' => 'application.test'
}
}

View File

@ -1,30 +0,0 @@
-----BEGIN PGP PUBLIC KEY BLOCK-----
Comment: Encryption subkey has been removed due to apt-key parsing bug
mQINBFhiI8wBEADThWLNd8IKPRw7Ygu3DHS4Sb/Yc6vSZSaMGJ6Wkj245jScvI+C
nG4C4rt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GAZTj2KlZfdJHmr+Oa
wY57giUYz7OF45LLCuqe+VwpGp2d3UK/MtCnXRLi5InMVJKDvyt18MzRDFuyA27e
WSt+JumVqhEjawh3hmdzIS1cHKmv19gdeE8On2i2Lf8lyek8fsB/YPgADAmp2oSe
cjLu0ocGbgxRjuCR29+6IG+DiUDFCkqFZNdLiGVqzjpjpYHaPhVe77ciwA8TCPru
3dh5t/qv2HglSd7lj95IApZBtny5AK8NS4qtaOeZbBbbDRuOPL0c7fU3bqyIPy57
zvdYi3KdjWZVCawcAmk3ILP83eFSivCRPRoyCqO+HX8U647BBWvlFuEbPa+Y1sgE
12MEF/Y6VVJh3Ptw+h/qKRbra4LdA+5Y30q/9l6WGgbO/4h3NKmGeVCrAFvS3h92
fS0ABYD1nAP7fSNS9RfYIqfBXtJem+tJ14YKJwWiAYU=
=TPyg
-----END PGP PUBLIC KEY BLOCK-----

View File

@ -8,20 +8,11 @@ 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/bin/gem"
confine :exists => "/opt/td-agent/embedded/bin/gem"
has_feature :versionable, :install_options
commands :gemcmd => "/opt/td-agent/bin/gem"
def install(useversion = true)
command = [command(:gemcmd), "install"]
command << "--no-document" << resource[:name]
output = execute(command)
# Apparently some stupid gem versions don't exit non-0 on failure
self.fail "Could not install: #{output.chomp}" if output.include?("ERROR")
end
commands :gemcmd => "/opt/td-agent/embedded/bin/gem"
def uninstall
command = [command(:gemcmd), "uninstall"]

View File

@ -28,8 +28,8 @@ define fluentd::config::file (
file { $config_path:
ensure => $ensure,
content => $content,
owner => $::fluentd::user_name,
group => $::fluentd::user_group,
owner => 'td-agent',
group => 'td-agent',
mode => '0644',
notify => Class['Fluentd::Service'],
}

View File

@ -38,16 +38,23 @@
# Copyright 2015 wywy, unless otherwise noted.
#
define fluentd::filter (
Enum['present', 'absent'] $ensure = present,
Integer $priority = 20,
String $pattern = '**',
Hash $config = {},
$ensure = present,
$priority = 20,
$pattern = '**',
$config = {},
) {
# parameter validation
if ! ($ensure in [ 'present', 'absent' ]) {
fail('ensure parameter must be present or absent')
}
validate_integer($priority)
validate_string($pattern)
validate_hash($config)
fluentd::config::file { "filter-${title}":
ensure => $ensure,
priority => $priority,
content => template( 'fluentd/filter.erb'),
}
}

View File

@ -8,9 +8,6 @@
# [*repo_manage*]
# Include repository to install recent fluentd (td-agent) from
# Default: 'true'
# [*repo_version*]
# The major version of td-agent to install
# Default: 3
# [*package_ensure*]
# Package ensure
# Default: 'installed'
@ -68,25 +65,37 @@
# Copyright 2015 wywy, unless otherwise noted.
#
class fluentd (
Boolean $repo_manage = $::fluentd::params::repo_manage,
Integer $repo_version = $::fluentd::params::repo_version,
String $package_ensure = $::fluentd::params::package_ensure,
String $package_name = $::fluentd::params::package_name,
Array $package_install_options = $::fluentd::params::package_install_options,
Boolean $service_manage = $::fluentd::params::service_manage,
String $service_name = $::fluentd::params::service_name,
Enum['running', 'stopped'] $service_ensure = $::fluentd::params::service_ensure,
Boolean $service_enable = $::fluentd::params::service_enable,
String $config_path = $::fluentd::params::config_path,
String $conf_dir = $::fluentd::params::conf_dir,
String $config_file = $::fluentd::params::config_file,
Boolean $conf_dir_manage = $::fluentd::params::conf_dir_manage,
Boolean $user_manage = $::fluentd::params::user_manage,
String $user_name = $::fluentd::params::user_name,
String $user_group = $::fluentd::params::user_group,
Array $user_groups = $::fluentd::params::user_groups,
$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,
$service_manage = $::fluentd::params::service_manage,
$service_name = $::fluentd::params::service_name,
$service_ensure = $::fluentd::params::service_ensure,
$service_enable = $::fluentd::params::service_enable,
$config_path = $::fluentd::params::config_path,
$conf_dir = $::fluentd::params::conf_dir,
$config_file = $::fluentd::params::config_file,
$conf_dir_manage = $::fluentd::params::conf_dir_manage,
$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($repo_manage)
validate_string($package_ensure)
validate_string($package_name)
validate_array($package_install_options)
validate_bool($service_manage)
validate_string($service_name)
validate_bool($service_enable)
if ! ($service_ensure in [ 'running', 'stopped' ]) {
fail('service_ensure parameter must be running or stopped')
}
# class calls
include '::fluentd::repo'
include '::fluentd::install'
@ -94,12 +103,6 @@ class fluentd (
include '::fluentd::config'
include '::fluentd::service'
# Realize any virtual configurations
Fluentd::Plugin <| |>
Fluentd::Source <| |>
Fluentd::Filter <| |>
Fluentd::Match <| |>
# dependencies
Class['::Fluentd::Repo']
-> Class['::Fluentd::Install']

View File

@ -43,16 +43,23 @@
# Copyright 2015 wywy, unless otherwise noted.
#
define fluentd::match (
Enum['present', 'absent'] $ensure = present,
Integer $priority = 30,
String $pattern = '**',
Hash $config = {},
$ensure = present,
$priority = 30,
$pattern = '**',
$config = {},
) {
# parameter validation
if ! ($ensure in [ 'present', 'absent' ]) {
fail('ensure parameter must be present or absent')
}
validate_integer($priority)
validate_string($pattern)
validate_hash($config)
fluentd::config::file { "match-${title}":
ensure => $ensure,
priority => $priority,
content => template( 'fluentd/match.erb'),
}
}

View File

@ -18,8 +18,6 @@ class fluentd::params {
$user_name = 'td-agent'
$user_group = 'td-agent'
$user_groups = ['adm']
# repo params
$repo_version = 4
case $::osfamily {
'Debian': {

View File

@ -26,9 +26,9 @@
# Copyright 2015 wywy, unless otherwise noted.
#
define fluentd::plugin (
String $ensure = present,
String $type = 'gem',
Optional[String] $source = undef,
$ensure = present,
$type = 'gem',
$source = undef,
) {
case $type {
@ -43,6 +43,7 @@ define fluentd::plugin (
if ! ($ensure in [ 'present', 'absent' ]) {
fail('ensure parameter must be present or absent')
}
validate_string($source)
fluentd::plugin::file { $name:
ensure => $ensure,

View File

@ -4,7 +4,7 @@ class fluentd::repo inherits fluentd {
if $::fluentd::repo_manage {
case $::osfamily {
'Debian': {
contain ::fluentd::repo::apt
include ::fluentd::repo::apt
}
'RedHat': {
include ::fluentd::repo::yum

View File

@ -2,13 +2,13 @@
#
class fluentd::repo::apt (
$ensure = 'present',
$location = downcase("http://packages.treasuredata.com/${::fluentd::repo_version}/${::lsbdistid}/${::lsbdistcodename}"),
$location = downcase("http://packages.treasuredata.com/2/${::lsbdistid}/${::lsbdistcodename}"),
$release = $::lsbdistcodename,
$repos = 'contrib',
$architecture = $::architecture,
$key = {
'id' => 'BEE682289B2217F45AF4CC3F901F9177AB97ACBE',
'content' => file('fluentd/GPG-KEY-td-agent'),
'id' => 'BEE682289B2217F45AF4CC3F901F9177AB97ACBE',
'source' => 'http://packages.treasuredata.com/GPG-KEY-td-agent'
},
$include = {
'src' => false,
@ -27,6 +27,4 @@ class fluentd::repo::apt (
key => $key,
include => $include,
}
Class['apt::update'] -> Package['fluentd']
}

View File

@ -3,7 +3,7 @@
class fluentd::repo::yum (
$ensure = 'present',
$descr = 'TreasureData',
$baseurl = "https://packages.treasuredata.com/${::fluentd::repo_version}/redhat/\$releasever/\$basearch",
$baseurl = 'https://packages.treasuredata.com/2/redhat/$releasever/$basearch',
$enabled = '1',
$gpgcheck = '1',
$gpgkey = 'https://packages.treasuredata.com/GPG-KEY-td-agent',

View File

@ -34,15 +34,17 @@
# Copyright 2015 wywy, unless otherwise noted.
#
define fluentd::source (
String $ensure = present,
Integer $priority = 10,
Hash $config = {},
$ensure = present,
$priority = 10,
$config = {},
) {
# parameter validation
if ! ($ensure in [ 'present', 'absent' ]) {
fail('ensure parameter must be present or absent')
}
validate_integer($priority)
validate_hash($config)
fluentd::config::file { "source-${title}":
ensure => $ensure,

View File

@ -1,17 +1,17 @@
{
"name": "pilchkinstein-fluentd",
"version": "1.0.0",
"author": "pilchkinstein-gtv",
"name": "wywygmbh-fluentd",
"version": "0.6.0",
"author": "wywy",
"summary": "Generic module for fluentd (td-agent).",
"license": "Apache-2.0",
"source": "https://github.com/pilchkinstein-gtv/puppet-fluentd",
"project_page": "https://github.com/pilchkinstein-gtv/puppet-fluentd",
"issues_url": "https://github.com/pilchkinstein-gtv/puppet-fluentd/issues",
"source": "https://github.com/wywy/puppet-fluentd",
"project_page": "https://github.com/wywy/puppet-fluentd",
"issues_url": "https://github.com/wywy/puppet-fluentd/issues",
"tags": ["fluentd", "td-agent"],
"operatingsystem_support": [
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [ "16.04", "14.04" ]
"operatingsystemrelease": [ "14.04", "12.04" ]
},
{
"operatingsystem": "Debian",
@ -24,7 +24,7 @@
],
"dependencies": [
{ "name": "puppetlabs/stdlib", "version_requirement": ">= 4.6.0 < 5.0.0" },
{ "name": "puppetlabs/apt", "version_requirement": ">= 4.0.0" }
{ "name": "puppetlabs/apt", "version_requirement": ">= 2.0.0 < 3.0.0" }
],
"data_provider": null
}

View File

@ -13,7 +13,7 @@ describe 'fluentd::filter' do
let(:title) { 'test' }
let(:params) do
{
priority: 20,
priority: '20',
pattern: '*.test',
config: {
'type' => 'record_transformer',

View File

@ -13,7 +13,7 @@ describe 'fluentd::match' do
let(:title) { 'test' }
let(:params) do
{
priority: 30,
priority: '30',
pattern: '*.test',
config: {
'flush_interval' => '30s',
@ -41,7 +41,7 @@ describe 'fluentd::match' do
let(:title) { 'test' }
let(:params) do
{
priority: 30,
priority: '30',
pattern: '*.test',
config: {
'type' => 'copy',

View File

@ -13,19 +13,11 @@ describe 'fluentd::source' do
let(:title) { 'test' }
let(:params) do
{
priority: 10,
priority: '10',
config: {
'type' => 'tail',
'format' => 'json',
'path' => '/var/log/test-application/*.json',
'parse' => {
'type' => 'regexp',
'expression' => '^(?<name>[^ ]*) (?<user>[^ ]*) (?<age>\d*)$'
},
'storage'=> {
'type' => 'local',
'path' => 'test.pos'
},
'tag' => 'application.test'
}
}

View File

@ -2,13 +2,5 @@
type tail
format json
path /var/log/test-application/*.json
<parse>
type regexp
expression ^(?<name>[^ ]*) (?<user>[^ ]*) (?<age>\d*)$
</parse>
<storage>
type local
path test.pos
</storage>
tag application.test
</source>

View File

@ -1,8 +1,7 @@
<match <%= @pattern %>>
<% @config.each do |key, val| -%>
<%- if key == 'buffer_chunk_keys'; next; end-%>
<%- if val.is_a?( Hash ) -%>
<<%= key -%><%- if key == 'buffer' && !@config['buffer_chunk_keys'].nil? -%> <%= @config['buffer_chunk_keys'] -%><%- end -%>>
<<%= key -%>>
<%- val.each do |key, val| -%>
<%= key -%> <%= val %>
<%- end -%>
@ -14,7 +13,7 @@
<%- k.each do |x, y| -%>
<%- if y.is_a?( Array ) -%>
<%- y.each do |a, b| -%>
<<%= x -%><%- if x == 'buffer' && !k['buffer_chunk_keys'].nil? -%> <%= k['buffer_chunk_keys'] -%><%- end -%>>
<<%= x -%>>
<%- if a.is_a?( Hash ) -%>
<%- a.each do |c, d| -%>
<%= c -%> <%= d %>
@ -25,7 +24,6 @@
</<%= x %>>
<%- end -%>
<%- else -%>
<%- if x == 'buffer_chunk_keys'; next; end -%>
<%= x -%> <%= y %>
<%- end -%>
<%- end -%>

View File

@ -1,13 +1,5 @@
<source>
<% @config.each do |key, val| -%>
<%- if val.is_a?( Hash ) -%>
<<%= key -%>>
<%- val.each do |key, val| -%>
<%= key -%> <%= val %>
<%- end -%>
</<%= key %>>
<%- else -%>
<%= key -%> <%= val %>
<%- end -%>
<% end -%>
</source>