├── .gitignore ├── spec ├── spec_helper.rb └── defines │ ├── output │ ├── logstash_output_null_spec.rb │ ├── logstash_output_internal_spec.rb │ ├── logstash_output_exec_spec.rb │ ├── logstash_output_websocket_spec.rb │ ├── logstash_output_pipe_spec.rb │ ├── logstash_output_stdout_spec.rb │ ├── logstash_output_opentsdb_spec.rb │ ├── logstash_output_tcp_spec.rb │ ├── logstash_output_circonus_spec.rb │ ├── logstash_output_gemfire_spec.rb │ ├── logstash_output_file_spec.rb │ ├── logstash_output_stomp_spec.rb │ ├── logstash_output_zeromq_spec.rb │ ├── logstash_output_nagios_spec.rb │ ├── logstash_output_xmpp_spec.rb │ ├── logstash_output_hipchat_spec.rb │ ├── logstash_output_riemann_spec.rb │ ├── logstash_output_elasticsearch_http_spec.rb │ ├── logstash_output_zabbix_spec.rb │ ├── logstash_output_juggernaut_spec.rb │ ├── logstash_output_sqs_spec.rb │ ├── logstash_output_loggly_spec.rb │ ├── logstash_output_pagerduty_spec.rb │ ├── logstash_output_ganglia_spec.rb │ ├── logstash_output_mongodb_spec.rb │ ├── logstash_output_lumberjack_spec.rb │ ├── logstash_output_librato_spec.rb │ ├── logstash_output_boundary_spec.rb │ ├── logstash_output_irc_spec.rb │ ├── logstash_output_graphtastic_spec.rb │ ├── logstash_output_datadog_spec.rb │ ├── logstash_output_http_spec.rb │ ├── logstash_output_sns_spec.rb │ └── logstash_output_statsd_spec.rb │ ├── filter │ ├── logstash_filter_noop_spec.rb │ ├── logstash_filter_gelfify_spec.rb │ ├── logstash_filter_grokdiscovery_spec.rb │ ├── logstash_filter_clone_spec.rb │ ├── logstash_filter_ruby_spec.rb │ ├── logstash_filter_date_spec.rb │ ├── logstash_filter_json_spec.rb │ ├── logstash_filter_split_spec.rb │ ├── logstash_filter_checksum_spec.rb │ ├── logstash_filter_urldecode_spec.rb │ ├── logstash_filter_environment_spec.rb │ ├── logstash_filter_sleep_spec.rb │ ├── logstash_filter_dns_spec.rb │ ├── logstash_filter_grep_spec.rb │ ├── logstash_filter_anonymize_spec.rb │ ├── logstash_filter_useragent_spec.rb │ ├── logstash_filter_alter_spec.rb │ ├── logstash_filter_metrics_spec.rb │ ├── logstash_filter_csv_spec.rb │ ├── logstash_filter_xml_spec.rb │ ├── logstash_filter_zeromq_spec.rb │ ├── logstash_filter_syslog_pri_spec.rb │ ├── logstash_filter_multiline_spec.rb │ ├── logstash_filter_geoip_spec.rb │ ├── logstash_filter_kv_spec.rb │ └── logstash_filter_prune_spec.rb │ └── input │ ├── logstash_input_stdin_spec.rb │ ├── logstash_input_heroku_spec.rb │ ├── logstash_input_pipe_spec.rb │ ├── logstash_input_varnishlog_spec.rb │ ├── logstash_input_eventlog_spec.rb │ ├── logstash_input_relp_spec.rb │ ├── logstash_input_ganglia_spec.rb │ ├── logstash_input_exec_spec.rb │ ├── logstash_input_websocket_spec.rb │ ├── logstash_input_gelf_spec.rb │ ├── logstash_input_udp_spec.rb │ ├── logstash_input_snmptrap_spec.rb │ ├── logstash_input_log4j_spec.rb │ ├── logstash_input_generator_spec.rb │ ├── logstash_input_xmpp_spec.rb │ ├── logstash_input_elasticsearch_spec.rb │ ├── logstash_input_drupal_dblog_spec.rb │ ├── logstash_input_stomp_spec.rb │ ├── logstash_input_syslog_spec.rb │ ├── logstash_input_zeromq_spec.rb │ └── logstash_input_irc_spec.rb ├── .fixtures.yml ├── .gemfile ├── Rakefile ├── files └── etc │ └── sysconfig │ └── logstash.defaults ├── Modulefile ├── templates └── etc │ └── pattern │ └── extras.erb ├── tests └── server.pp ├── CONTRIBUTORS ├── manifests ├── pattern_files.pp ├── pattern.pp ├── java.pp ├── config.pp ├── params.pp └── configdir.pp ├── .travis.yml ├── LICENSE ├── lib └── puppet │ └── parser │ └── functions │ └── suffix.rb ├── CONTRIBUTING.md └── CHANGELOG /.gitignore: -------------------------------------------------------------------------------- 1 | spec/fixtures 2 | 3 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'puppetlabs_spec_helper/module_spec_helper' 3 | -------------------------------------------------------------------------------- /.fixtures.yml: -------------------------------------------------------------------------------- 1 | fixtures: 2 | repositories: 3 | stdlib: git://github.com/puppetlabs/puppetlabs-stdlib.git 4 | symlinks: 5 | logstash: "#{source_dir}" 6 | -------------------------------------------------------------------------------- /.gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | puppetversion = ENV['PUPPET_VERSION'] 4 | gem 'puppet', puppetversion, :require => false 5 | gem 'puppet-lint' 6 | gem 'rspec-puppet' 7 | gem 'puppetlabs_spec_helper', '>= 0.1.0' 8 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'puppetlabs_spec_helper/rake_tasks' 3 | require 'puppet-lint' 4 | PuppetLint.configuration.send("disable_80chars") 5 | PuppetLint.configuration.send("disable_class_inherits_from_params_class") 6 | -------------------------------------------------------------------------------- /files/etc/sysconfig/logstash.defaults: -------------------------------------------------------------------------------- 1 | # Start logstash 2 | START=true 3 | 4 | # Java options 5 | LS_JAVA_OPTS="${LS_JAVA_OPTS} -Xmx256m" 6 | 7 | # Open files limit 8 | #OPEN_FILES=2049 9 | 10 | # Nice setting 11 | #NICE=19 12 | 13 | # Number of filter threads ( default 1 ) 14 | #FILTER_THREADS=1 15 | -------------------------------------------------------------------------------- /Modulefile: -------------------------------------------------------------------------------- 1 | name 'puppet-logstash' 2 | version '0.3.3' 3 | source 'https://github.com/zen/puppet-logstash' 4 | author 'ispavailability' 5 | license 'Apache License, Version 2.0' 6 | summary 'Module for managing and configuring Logstash' 7 | description 'Module for managing and configuring Logstash' 8 | project_page 'https://github.com/zen/puppet-logstash' 9 | dependency 'puppetlabs/stdlib', '>= 3.0.0' 10 | -------------------------------------------------------------------------------- /templates/etc/pattern/extras.erb: -------------------------------------------------------------------------------- 1 | AUDITLOGLEVEL ([C|c]ritical|CRITICAL[A|a]udit|AUDIT|[D|d]ebug|DEBUG|[N|n]otice|NOTICE|[I|i]nfo|INFO|[W|w]arn?(?:ing)?|WARN?(?:ING)?|[E|e]rr?(?:or)?|ERR?(?:OR)?|[C|c]rit?(?:ical)?|CRIT?(?:ICAL)?|[F|f]atal|FATAL|[S|s]evere|SEVERE) 2 | 3 | APACHE_LOG_LEVEL (?:emerg|alert|crit|error|warn|notice|info|debug) 4 | 5 | APACHE_DATETIME_ERROR %{DAY} %{MONTH} %{MONTHDAY} %{TIME} %{YEAR} 6 | 7 | RABBITMQ_DATE %{MONTHDAY}-%{MONTH}-%{YEAR}::%{TIME} 8 | -------------------------------------------------------------------------------- /tests/server.pp: -------------------------------------------------------------------------------- 1 | class { 'logstash': 2 | status => 'enabled', 3 | multi_instance => false, 4 | patternfiles => ['grok-patterns', 'extras'], 5 | } 6 | logstash::input::zeromq { 'input_zeromq': 7 | type => 'zeromq', 8 | address => ['tcp://*:2120'], 9 | topology => 'pushpull', 10 | mode => 'server', 11 | } 12 | logstash::output::elasticsearch { 'output_elasticsearch': 13 | embedded => true, 14 | bind_host => '0.0.0.0' 15 | } 16 | -------------------------------------------------------------------------------- /CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | The following is a list of people who have contributed ideas, code, bug 2 | reports, or in general have helped this puppet module along its way. 3 | 4 | Project Owner 5 | * Richard Pijnenburg (electrical) 6 | 7 | Contributors: 8 | * Jordan Sissel (jordansissel) 9 | * Dan (phrawzty) 10 | * Garth Kidd (garthk) 11 | * Tavis Aitken (tavisto) 12 | * pkubat 13 | * Jeff Wong (awole20) 14 | * Bob (rjw1) 15 | * Dan Carley (dcarley) 16 | * Brian Lalor (blalor) 17 | * Justin Lambert (jlambert) 18 | * Richard Peng (richardpeng) 19 | -------------------------------------------------------------------------------- /manifests/pattern_files.pp: -------------------------------------------------------------------------------- 1 | # == Define: pattern_files 2 | # 3 | # === Authors 4 | # 5 | # * Bartosz Kupidura 6 | # * Tomasz Z. Napierala 7 | # 8 | define logstash::pattern_files( 9 | $pattern_dir = undef, 10 | $services = undef, 11 | ) { 12 | file { "${pattern_dir}/${name}": 13 | mode => '0440', 14 | require => File[$pattern_dir], 15 | content => template("${module_name}/etc/pattern/${name}.erb"), 16 | notify => Service[$services] 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | rvm: 3 | - 1.9.3 4 | - 2.0.0 5 | script: 6 | - "rake lint" 7 | - "rake spec SPEC_OPTS='--format documentation'" 8 | env: 9 | - PUPPET_VERSION="~> 3.0.0" 10 | - PUPPET_VERSION="~> 3.1.0" 11 | - PUPPET_VERSION="~> 3.2.0" 12 | - PUPPET_VERSION="~> 3.3.0" 13 | matrix: 14 | allow_failures: 15 | - rvm: ruby-head 16 | exclude: 17 | - rvm: 1.9.3 18 | env: PUPPET_GEM_VERSION="~> 2.7.0" 19 | - rvm: ruby-head 20 | env: PUPPET_GEM_VERSION="~> 2.7.0" 21 | gemfile: .gemfile 22 | notifications: 23 | email: 24 | - tomasz@napierala.org 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2012-2013 Richard Pijnenburg 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /manifests/pattern.pp: -------------------------------------------------------------------------------- 1 | # == Define: logstash::pattern 2 | # 3 | # * Bartosz Kupidura 4 | # 5 | 6 | # == Class:logstash::pattern 7 | # 8 | class logstash::pattern( 9 | $instances = [ 'agent' ] 10 | ) { 11 | 12 | require logstash::params 13 | 14 | if $logstash::multi_instance == true { 15 | $confdirstart = prefix($instances, "${logstash::configdir}/") 16 | $pattern_dir = suffix($confdirstart, '/pattern') 17 | $services = prefix($instances, 'logstash-') 18 | } else { 19 | $pattern_dir = "${logstash::configdir}/conf.d/pattern" 20 | $services = 'logstash' 21 | } 22 | 23 | if $logstash::ensure == 'present' { 24 | 25 | File { 26 | owner => $logstash::logstash_user, 27 | group => $logstash::logstash_group, 28 | } 29 | 30 | #### Manage the config directory 31 | pattern_files { $logstash::patternfiles: pattern_dir => $pattern_dir, services => $services } 32 | 33 | } else { 34 | notify {'Not if':} 35 | #### Do we need to do anything to remove directories? 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /lib/puppet/parser/functions/suffix.rb: -------------------------------------------------------------------------------- 1 | # 2 | # suffix.rb 3 | # 4 | 5 | module Puppet::Parser::Functions 6 | newfunction(:suffix, :type => :rvalue, :doc => <<-EOS 7 | This function applies a suffix to all elements in an array. 8 | 9 | *Examples:* 10 | 11 | suffix(['a','b','c'], 'p') 12 | 13 | Will return: ['ap','bp','cp'] 14 | EOS 15 | ) do |arguments| 16 | 17 | # Technically we support two arguments but only first is mandatory ... 18 | raise(Puppet::ParseError, "suffix(): Wrong number of arguments " + 19 | "given (#{arguments.size} for 1)") if arguments.size < 1 20 | 21 | array = arguments[0] 22 | 23 | unless array.is_a?(Array) 24 | raise(Puppet::ParseError, 'suffix(): Requires array to work with') 25 | end 26 | 27 | suffix = arguments[1] if arguments[1] 28 | 29 | if suffix 30 | unless suffix.is_a?(String) 31 | raise(Puppet::ParseError, 'suffix(): Requires string to work with') 32 | end 33 | end 34 | 35 | # Turn everything into string same as join would do ... 36 | result = array.collect do |i| 37 | i = i.to_s 38 | suffix ? i + suffix : i 39 | end 40 | 41 | return result 42 | end 43 | end 44 | 45 | # vim: set ts=2 sw=2 et : 46 | -------------------------------------------------------------------------------- /manifests/java.pp: -------------------------------------------------------------------------------- 1 | # == Class: logstash::java 2 | # 3 | # This class exists to install java if its not managed from an other module 4 | # 5 | # 6 | # === Parameters 7 | # 8 | # This class does not provide any parameters. 9 | # 10 | # 11 | # === Examples 12 | # 13 | # This class may be imported by other classes to use its functionality: 14 | # class { 'logstash::java': } 15 | # 16 | # It is not intended to be used directly by external resources like node 17 | # definitions or other modules. 18 | # 19 | # 20 | # === Authors 21 | # 22 | # * Richard Pijnenburg 23 | # 24 | class logstash::java { 25 | 26 | if $logstash::java_package == undef { 27 | # Default Java package 28 | case $::operatingsystem { 29 | 'CentOS', 'Fedora', 'Scientific', 'RedHat', 'Amazon': { 30 | $package = 'java-1.6.0-openjdk' 31 | } 32 | 'Debian', 'Ubuntu': { 33 | $package = 'openjdk-6-jre-headless' 34 | } 35 | default: { 36 | fail("\"${module_name}\" provides no java package 37 | for \"${::operatingsystem}\"") 38 | } 39 | } 40 | } else { 41 | $package = $logstash::java_package 42 | } 43 | 44 | ## Install the java package unless already specified somewhere else 45 | if !defined(Package[$package]) { 46 | package { $package: 47 | ensure => present 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /spec/defines/output/logstash_output_null_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::output::null', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :exclude_tags => ['value1'], 13 | :fields => ['value2'], 14 | :tags => ['value3'], 15 | :type => 'value4', 16 | } end 17 | 18 | it { should contain_file('/etc/logstash/agent/config/output_null_test').with(:content => "output {\n null {\n exclude_tags => ['value1']\n fields => ['value2']\n tags => ['value3']\n type => \"value4\"\n }\n}\n") } 19 | end 20 | 21 | context "Instance test" do 22 | 23 | let :params do { 24 | :exclude_tags => ['value1'], 25 | :fields => ['value2'], 26 | :tags => ['value3'], 27 | :type => 'value4', 28 | :instances => [ 'agent1', 'agent2' ] 29 | } end 30 | 31 | it { should contain_file('/etc/logstash/agent1/config/output_null_test') } 32 | it { should contain_file('/etc/logstash/agent2/config/output_null_test') } 33 | 34 | end 35 | 36 | context "Set file owner" do 37 | 38 | let(:facts) { {:operatingsystem => 'CentOS' }} 39 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 40 | let(:title) { 'test' } 41 | 42 | let :params do { 43 | :exclude_tags => ['value1'], 44 | :fields => ['value2'], 45 | :tags => ['value3'], 46 | :type => 'value4', 47 | } end 48 | 49 | it { should contain_file('/etc/logstash/agent/config/output_null_test').with(:owner => 'logstash', :group => 'logstash') } 50 | 51 | end 52 | 53 | end 54 | -------------------------------------------------------------------------------- /spec/defines/output/logstash_output_internal_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::output::internal', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :exclude_tags => ['value1'], 13 | :fields => ['value2'], 14 | :tags => ['value3'], 15 | :type => 'value4', 16 | } end 17 | 18 | it { should contain_file('/etc/logstash/agent/config/output_internal_test').with(:content => "output {\n internal {\n exclude_tags => ['value1']\n fields => ['value2']\n tags => ['value3']\n type => \"value4\"\n }\n}\n") } 19 | end 20 | 21 | context "Instance test" do 22 | 23 | let :params do { 24 | :exclude_tags => ['value1'], 25 | :fields => ['value2'], 26 | :tags => ['value3'], 27 | :type => 'value4', 28 | :instances => [ 'agent1', 'agent2' ] 29 | } end 30 | 31 | it { should contain_file('/etc/logstash/agent1/config/output_internal_test') } 32 | it { should contain_file('/etc/logstash/agent2/config/output_internal_test') } 33 | 34 | end 35 | 36 | context "Set file owner" do 37 | 38 | let(:facts) { {:operatingsystem => 'CentOS' }} 39 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 40 | let(:title) { 'test' } 41 | 42 | let :params do { 43 | :exclude_tags => ['value1'], 44 | :fields => ['value2'], 45 | :tags => ['value3'], 46 | :type => 'value4', 47 | } end 48 | 49 | it { should contain_file('/etc/logstash/agent/config/output_internal_test').with(:owner => 'logstash', :group => 'logstash') } 50 | 51 | end 52 | 53 | end 54 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | If you have a bugfix or new feature that you would like to contribute to this puppet module, please find or open an issue about it first. Talk about what you would like to do. It may be that somebody is already working on it, or that there are particular issues that you should know about before implementing the change. 2 | 3 | We enjoy working with contributors to get their code accepted. There are many approaches to fixing a problem and it is important to find the best approach before writing too much code. 4 | 5 | The process for contributing to any of the Elasticsearch repositories is similar. 6 | 7 | 1. Sign the contributor license agreement 8 | Please make sure you have signed the [Contributor License Agreement](http://www.elasticsearch.org/contributor-agreement/). We are not asking you to assign copyright to us, but to give us the right to distribute your code without restriction. We ask this of all contributors in order to assure our users of the origin and continuing existence of the code. You only need to sign the CLA once. 9 | 10 | 2. Run the rspec tests and ensure it completes without errors with your changes. 11 | 12 | 3. Rebase your changes 13 | Update your local repository with the most recent code from the main this puppet module repository, and rebase your branch on top of the latest master branch. We prefer your changes to be squashed into a single commit. 14 | 15 | 4. Submit a pull request 16 | Push your local changes to your forked copy of the repository and submit a pull request. In the pull request, describe what your changes do and mention the number of the issue where discussion has taken place, eg “Closes #123″. 17 | 18 | Then sit back and wait. There will probably be discussion about the pull request and, if any changes are needed, we would love to work with you to get your pull request merged into this puppet module. 19 | -------------------------------------------------------------------------------- /spec/defines/output/logstash_output_exec_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::output::exec', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :command => 'value1', 13 | :exclude_tags => ['value2'], 14 | :fields => ['value3'], 15 | :tags => ['value4'], 16 | :type => 'value5', 17 | } end 18 | 19 | it { should contain_file('/etc/logstash/agent/config/output_exec_test').with(:content => "output {\n exec {\n command => \"value1\"\n exclude_tags => ['value2']\n fields => ['value3']\n tags => ['value4']\n type => \"value5\"\n }\n}\n") } 20 | end 21 | 22 | context "Instance test" do 23 | 24 | let :params do { 25 | :command => 'value1', 26 | :exclude_tags => ['value2'], 27 | :fields => ['value3'], 28 | :tags => ['value4'], 29 | :type => 'value5', 30 | :instances => [ 'agent1', 'agent2' ] 31 | } end 32 | 33 | it { should contain_file('/etc/logstash/agent1/config/output_exec_test') } 34 | it { should contain_file('/etc/logstash/agent2/config/output_exec_test') } 35 | 36 | end 37 | 38 | context "Set file owner" do 39 | 40 | let(:facts) { {:operatingsystem => 'CentOS' }} 41 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 42 | let(:title) { 'test' } 43 | 44 | let :params do { 45 | :command => 'value1', 46 | :exclude_tags => ['value2'], 47 | :fields => ['value3'], 48 | :tags => ['value4'], 49 | :type => 'value5', 50 | } end 51 | 52 | it { should contain_file('/etc/logstash/agent/config/output_exec_test').with(:owner => 'logstash', :group => 'logstash') } 53 | 54 | end 55 | 56 | end 57 | -------------------------------------------------------------------------------- /spec/defines/output/logstash_output_websocket_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::output::websocket', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :exclude_tags => ['value1'], 13 | :fields => ['value2'], 14 | :host => 'value3', 15 | :port => 4, 16 | :tags => ['value5'], 17 | :type => 'value6', 18 | } end 19 | 20 | it { should contain_file('/etc/logstash/agent/config/output_websocket_test').with(:content => "output {\n websocket {\n exclude_tags => ['value1']\n fields => ['value2']\n host => \"value3\"\n port => 4\n tags => ['value5']\n type => \"value6\"\n }\n}\n") } 21 | end 22 | 23 | context "Instance test" do 24 | 25 | let :params do { 26 | :exclude_tags => ['value1'], 27 | :fields => ['value2'], 28 | :host => 'value3', 29 | :port => 4, 30 | :tags => ['value5'], 31 | :type => 'value6', 32 | :instances => [ 'agent1', 'agent2' ] 33 | } end 34 | 35 | it { should contain_file('/etc/logstash/agent1/config/output_websocket_test') } 36 | it { should contain_file('/etc/logstash/agent2/config/output_websocket_test') } 37 | 38 | end 39 | 40 | context "Set file owner" do 41 | 42 | let(:facts) { {:operatingsystem => 'CentOS' }} 43 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 44 | let(:title) { 'test' } 45 | 46 | let :params do { 47 | :exclude_tags => ['value1'], 48 | :fields => ['value2'], 49 | :host => 'value3', 50 | :port => 4, 51 | :tags => ['value5'], 52 | :type => 'value6', 53 | } end 54 | 55 | it { should contain_file('/etc/logstash/agent/config/output_websocket_test').with(:owner => 'logstash', :group => 'logstash') } 56 | 57 | end 58 | 59 | end 60 | -------------------------------------------------------------------------------- /spec/defines/filter/logstash_filter_noop_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::filter::noop', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :add_tag => ['value2'], 14 | :exclude_tags => ['value3'], 15 | :remove_tag => ['value4'], 16 | :tags => ['value5'], 17 | :type => 'value6', 18 | } end 19 | 20 | it { should contain_file('/etc/logstash/agent/config/filter_10_noop_test').with(:content => "filter {\n noop {\n add_field => [\"field1\", \"value1\"]\n add_tag => ['value2']\n exclude_tags => ['value3']\n remove_tag => ['value4']\n tags => ['value5']\n type => \"value6\"\n }\n}\n") } 21 | end 22 | 23 | context "Instance test" do 24 | 25 | let :params do { 26 | :add_field => { 'field1' => 'value1' }, 27 | :add_tag => ['value2'], 28 | :exclude_tags => ['value3'], 29 | :remove_tag => ['value4'], 30 | :tags => ['value5'], 31 | :type => 'value6', 32 | :instances => [ 'agent1', 'agent2' ] 33 | } end 34 | 35 | it { should contain_file('/etc/logstash/agent1/config/filter_10_noop_test') } 36 | it { should contain_file('/etc/logstash/agent2/config/filter_10_noop_test') } 37 | 38 | end 39 | 40 | context "Set file owner" do 41 | 42 | let(:facts) { {:operatingsystem => 'CentOS' }} 43 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 44 | let(:title) { 'test' } 45 | 46 | let :params do { 47 | :add_field => { 'field1' => 'value1' }, 48 | :add_tag => ['value2'], 49 | :exclude_tags => ['value3'], 50 | :remove_tag => ['value4'], 51 | :tags => ['value5'], 52 | :type => 'value6', 53 | } end 54 | 55 | it { should contain_file('/etc/logstash/agent/config/filter_10_noop_test').with(:owner => 'logstash', :group => 'logstash') } 56 | 57 | end 58 | 59 | end 60 | -------------------------------------------------------------------------------- /spec/defines/output/logstash_output_pipe_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::output::pipe', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :command => 'value1', 13 | :exclude_tags => ['value2'], 14 | :fields => ['value3'], 15 | :message_format => 'value4', 16 | :tags => ['value5'], 17 | :ttl => 6, 18 | :type => 'value7', 19 | } end 20 | 21 | it { should contain_file('/etc/logstash/agent/config/output_pipe_test').with(:content => "output {\n pipe {\n command => \"value1\"\n exclude_tags => ['value2']\n fields => ['value3']\n message_format => \"value4\"\n tags => ['value5']\n ttl => 6\n type => \"value7\"\n }\n}\n") } 22 | end 23 | 24 | context "Instance test" do 25 | 26 | let :params do { 27 | :command => 'value1', 28 | :exclude_tags => ['value2'], 29 | :fields => ['value3'], 30 | :message_format => 'value4', 31 | :tags => ['value5'], 32 | :ttl => 6, 33 | :type => 'value7', 34 | :instances => [ 'agent1', 'agent2' ] 35 | } end 36 | 37 | it { should contain_file('/etc/logstash/agent1/config/output_pipe_test') } 38 | it { should contain_file('/etc/logstash/agent2/config/output_pipe_test') } 39 | 40 | end 41 | 42 | context "Set file owner" do 43 | 44 | let(:facts) { {:operatingsystem => 'CentOS' }} 45 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 46 | let(:title) { 'test' } 47 | 48 | let :params do { 49 | :command => 'value1', 50 | :exclude_tags => ['value2'], 51 | :fields => ['value3'], 52 | :message_format => 'value4', 53 | :tags => ['value5'], 54 | :ttl => 6, 55 | :type => 'value7', 56 | } end 57 | 58 | it { should contain_file('/etc/logstash/agent/config/output_pipe_test').with(:owner => 'logstash', :group => 'logstash') } 59 | 60 | end 61 | 62 | end 63 | -------------------------------------------------------------------------------- /spec/defines/filter/logstash_filter_gelfify_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::filter::gelfify', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :add_tag => ['value2'], 14 | :exclude_tags => ['value3'], 15 | :remove_tag => ['value4'], 16 | :tags => ['value5'], 17 | :type => 'value6', 18 | } end 19 | 20 | it { should contain_file('/etc/logstash/agent/config/filter_10_gelfify_test').with(:content => "filter {\n gelfify {\n add_field => [\"field1\", \"value1\"]\n add_tag => ['value2']\n exclude_tags => ['value3']\n remove_tag => ['value4']\n tags => ['value5']\n type => \"value6\"\n }\n}\n") } 21 | end 22 | 23 | context "Instance test" do 24 | 25 | let :params do { 26 | :add_field => { 'field1' => 'value1' }, 27 | :add_tag => ['value2'], 28 | :exclude_tags => ['value3'], 29 | :remove_tag => ['value4'], 30 | :tags => ['value5'], 31 | :type => 'value6', 32 | :instances => [ 'agent1', 'agent2' ] 33 | } end 34 | 35 | it { should contain_file('/etc/logstash/agent1/config/filter_10_gelfify_test') } 36 | it { should contain_file('/etc/logstash/agent2/config/filter_10_gelfify_test') } 37 | 38 | end 39 | 40 | context "Set file owner" do 41 | 42 | let(:facts) { {:operatingsystem => 'CentOS' }} 43 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 44 | let(:title) { 'test' } 45 | 46 | let :params do { 47 | :add_field => { 'field1' => 'value1' }, 48 | :add_tag => ['value2'], 49 | :exclude_tags => ['value3'], 50 | :remove_tag => ['value4'], 51 | :tags => ['value5'], 52 | :type => 'value6', 53 | } end 54 | 55 | it { should contain_file('/etc/logstash/agent/config/filter_10_gelfify_test').with(:owner => 'logstash', :group => 'logstash') } 56 | 57 | end 58 | 59 | end 60 | -------------------------------------------------------------------------------- /spec/defines/output/logstash_output_stdout_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::output::stdout', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :debug => false, 13 | :debug_format => 'ruby', 14 | :exclude_tags => ['value3'], 15 | :fields => ['value4'], 16 | :message => 'value5', 17 | :tags => ['value6'], 18 | :type => 'value7', 19 | } end 20 | 21 | it { should contain_file('/etc/logstash/agent/config/output_stdout_test').with(:content => "output {\n stdout {\n debug => false\n debug_format => \"ruby\"\n exclude_tags => ['value3']\n fields => ['value4']\n message => \"value5\"\n tags => ['value6']\n type => \"value7\"\n }\n}\n") } 22 | end 23 | 24 | context "Instance test" do 25 | 26 | let :params do { 27 | :debug => false, 28 | :debug_format => 'ruby', 29 | :exclude_tags => ['value3'], 30 | :fields => ['value4'], 31 | :message => 'value5', 32 | :tags => ['value6'], 33 | :type => 'value7', 34 | :instances => [ 'agent1', 'agent2' ] 35 | } end 36 | 37 | it { should contain_file('/etc/logstash/agent1/config/output_stdout_test') } 38 | it { should contain_file('/etc/logstash/agent2/config/output_stdout_test') } 39 | 40 | end 41 | 42 | context "Set file owner" do 43 | 44 | let(:facts) { {:operatingsystem => 'CentOS' }} 45 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 46 | let(:title) { 'test' } 47 | 48 | let :params do { 49 | :debug => false, 50 | :debug_format => 'ruby', 51 | :exclude_tags => ['value3'], 52 | :fields => ['value4'], 53 | :message => 'value5', 54 | :tags => ['value6'], 55 | :type => 'value7', 56 | } end 57 | 58 | it { should contain_file('/etc/logstash/agent/config/output_stdout_test').with(:owner => 'logstash', :group => 'logstash') } 59 | 60 | end 61 | 62 | end 63 | -------------------------------------------------------------------------------- /spec/defines/filter/logstash_filter_grokdiscovery_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::filter::grokdiscovery', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :add_tag => ['value2'], 14 | :exclude_tags => ['value3'], 15 | :remove_tag => ['value4'], 16 | :tags => ['value5'], 17 | :type => 'value6', 18 | } end 19 | 20 | it { should contain_file('/etc/logstash/agent/config/filter_10_grokdiscovery_test').with(:content => "filter {\n grokdiscovery {\n add_field => [\"field1\", \"value1\"]\n add_tag => ['value2']\n exclude_tags => ['value3']\n remove_tag => ['value4']\n tags => ['value5']\n type => \"value6\"\n }\n}\n") } 21 | end 22 | 23 | context "Instance test" do 24 | 25 | let :params do { 26 | :add_field => { 'field1' => 'value1' }, 27 | :add_tag => ['value2'], 28 | :exclude_tags => ['value3'], 29 | :remove_tag => ['value4'], 30 | :tags => ['value5'], 31 | :type => 'value6', 32 | :instances => [ 'agent1', 'agent2' ] 33 | } end 34 | 35 | it { should contain_file('/etc/logstash/agent1/config/filter_10_grokdiscovery_test') } 36 | it { should contain_file('/etc/logstash/agent2/config/filter_10_grokdiscovery_test') } 37 | 38 | end 39 | 40 | context "Set file owner" do 41 | 42 | let(:facts) { {:operatingsystem => 'CentOS' }} 43 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 44 | let(:title) { 'test' } 45 | 46 | let :params do { 47 | :add_field => { 'field1' => 'value1' }, 48 | :add_tag => ['value2'], 49 | :exclude_tags => ['value3'], 50 | :remove_tag => ['value4'], 51 | :tags => ['value5'], 52 | :type => 'value6', 53 | } end 54 | 55 | it { should contain_file('/etc/logstash/agent/config/filter_10_grokdiscovery_test').with(:owner => 'logstash', :group => 'logstash') } 56 | 57 | end 58 | 59 | end 60 | -------------------------------------------------------------------------------- /spec/defines/input/logstash_input_stdin_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::input::stdin', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :charset => 'ASCII-8BIT', 14 | :debug => false, 15 | :format => 'plain', 16 | :message_format => 'value5', 17 | :tags => ['value6'], 18 | :type => 'value7', 19 | } end 20 | 21 | it { should contain_file('/etc/logstash/agent/config/input_stdin_test').with(:content => "input {\n stdin {\n add_field => [\"field1\", \"value1\"]\n charset => \"ASCII-8BIT\"\n debug => false\n format => \"plain\"\n message_format => \"value5\"\n tags => ['value6']\n type => \"value7\"\n }\n}\n") } 22 | end 23 | 24 | context "Instance test" do 25 | 26 | let :params do { 27 | :add_field => { 'field1' => 'value1' }, 28 | :charset => 'ASCII-8BIT', 29 | :debug => false, 30 | :format => 'plain', 31 | :message_format => 'value5', 32 | :tags => ['value6'], 33 | :type => 'value7', 34 | :instances => [ 'agent1', 'agent2' ] 35 | } end 36 | 37 | it { should contain_file('/etc/logstash/agent1/config/input_stdin_test') } 38 | it { should contain_file('/etc/logstash/agent2/config/input_stdin_test') } 39 | 40 | end 41 | 42 | context "Set file owner" do 43 | 44 | let(:facts) { {:operatingsystem => 'CentOS' }} 45 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 46 | let(:title) { 'test' } 47 | 48 | let :params do { 49 | :add_field => { 'field1' => 'value1' }, 50 | :charset => 'ASCII-8BIT', 51 | :debug => false, 52 | :format => 'plain', 53 | :message_format => 'value5', 54 | :tags => ['value6'], 55 | :type => 'value7', 56 | } end 57 | 58 | it { should contain_file('/etc/logstash/agent/config/input_stdin_test').with(:owner => 'logstash', :group => 'logstash') } 59 | 60 | end 61 | 62 | end 63 | -------------------------------------------------------------------------------- /spec/defines/output/logstash_output_opentsdb_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::output::opentsdb', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :debug => false, 13 | :exclude_tags => ['value2'], 14 | :fields => ['value3'], 15 | :host => 'value4', 16 | :metrics => ['value5'], 17 | :port => 6, 18 | :tags => ['value7'], 19 | :type => 'value8', 20 | } end 21 | 22 | it { should contain_file('/etc/logstash/agent/config/output_opentsdb_test').with(:content => "output {\n opentsdb {\n debug => false\n exclude_tags => ['value2']\n fields => ['value3']\n host => \"value4\"\n metrics => ['value5']\n port => 6\n tags => ['value7']\n type => \"value8\"\n }\n}\n") } 23 | end 24 | 25 | context "Instance test" do 26 | 27 | let :params do { 28 | :debug => false, 29 | :exclude_tags => ['value2'], 30 | :fields => ['value3'], 31 | :host => 'value4', 32 | :metrics => ['value5'], 33 | :port => 6, 34 | :tags => ['value7'], 35 | :type => 'value8', 36 | :instances => [ 'agent1', 'agent2' ] 37 | } end 38 | 39 | it { should contain_file('/etc/logstash/agent1/config/output_opentsdb_test') } 40 | it { should contain_file('/etc/logstash/agent2/config/output_opentsdb_test') } 41 | 42 | end 43 | 44 | context "Set file owner" do 45 | 46 | let(:facts) { {:operatingsystem => 'CentOS' }} 47 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 48 | let(:title) { 'test' } 49 | 50 | let :params do { 51 | :debug => false, 52 | :exclude_tags => ['value2'], 53 | :fields => ['value3'], 54 | :host => 'value4', 55 | :metrics => ['value5'], 56 | :port => 6, 57 | :tags => ['value7'], 58 | :type => 'value8', 59 | } end 60 | 61 | it { should contain_file('/etc/logstash/agent/config/output_opentsdb_test').with(:owner => 'logstash', :group => 'logstash') } 62 | 63 | end 64 | 65 | end 66 | -------------------------------------------------------------------------------- /spec/defines/output/logstash_output_tcp_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::output::tcp', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :exclude_tags => ['value1'], 13 | :fields => ['value2'], 14 | :host => 'value3', 15 | :message_format => 'value4', 16 | :mode => 'server', 17 | :port => 6, 18 | :tags => ['value7'], 19 | :type => 'value8', 20 | } end 21 | 22 | it { should contain_file('/etc/logstash/agent/config/output_tcp_test').with(:content => "output {\n tcp {\n exclude_tags => ['value1']\n fields => ['value2']\n host => \"value3\"\n message_format => \"value4\"\n mode => \"server\"\n port => 6\n tags => ['value7']\n type => \"value8\"\n }\n}\n") } 23 | end 24 | 25 | context "Instance test" do 26 | 27 | let :params do { 28 | :exclude_tags => ['value1'], 29 | :fields => ['value2'], 30 | :host => 'value3', 31 | :message_format => 'value4', 32 | :mode => 'server', 33 | :port => 6, 34 | :tags => ['value7'], 35 | :type => 'value8', 36 | :instances => [ 'agent1', 'agent2' ] 37 | } end 38 | 39 | it { should contain_file('/etc/logstash/agent1/config/output_tcp_test') } 40 | it { should contain_file('/etc/logstash/agent2/config/output_tcp_test') } 41 | 42 | end 43 | 44 | context "Set file owner" do 45 | 46 | let(:facts) { {:operatingsystem => 'CentOS' }} 47 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 48 | let(:title) { 'test' } 49 | 50 | let :params do { 51 | :exclude_tags => ['value1'], 52 | :fields => ['value2'], 53 | :host => 'value3', 54 | :message_format => 'value4', 55 | :mode => 'server', 56 | :port => 6, 57 | :tags => ['value7'], 58 | :type => 'value8', 59 | } end 60 | 61 | it { should contain_file('/etc/logstash/agent/config/output_tcp_test').with(:owner => 'logstash', :group => 'logstash') } 62 | 63 | end 64 | 65 | end 66 | -------------------------------------------------------------------------------- /spec/defines/filter/logstash_filter_clone_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::filter::clone', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :add_tag => ['value2'], 14 | :clones => ['value3'], 15 | :exclude_tags => ['value4'], 16 | :remove_tag => ['value5'], 17 | :tags => ['value6'], 18 | :type => 'value7', 19 | } end 20 | 21 | it { should contain_file('/etc/logstash/agent/config/filter_10_clone_test').with(:content => "filter {\n clone {\n add_field => [\"field1\", \"value1\"]\n add_tag => ['value2']\n clones => ['value3']\n exclude_tags => ['value4']\n remove_tag => ['value5']\n tags => ['value6']\n type => \"value7\"\n }\n}\n") } 22 | end 23 | 24 | context "Instance test" do 25 | 26 | let :params do { 27 | :add_field => { 'field1' => 'value1' }, 28 | :add_tag => ['value2'], 29 | :clones => ['value3'], 30 | :exclude_tags => ['value4'], 31 | :remove_tag => ['value5'], 32 | :tags => ['value6'], 33 | :type => 'value7', 34 | :instances => [ 'agent1', 'agent2' ] 35 | } end 36 | 37 | it { should contain_file('/etc/logstash/agent1/config/filter_10_clone_test') } 38 | it { should contain_file('/etc/logstash/agent2/config/filter_10_clone_test') } 39 | 40 | end 41 | 42 | context "Set file owner" do 43 | 44 | let(:facts) { {:operatingsystem => 'CentOS' }} 45 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 46 | let(:title) { 'test' } 47 | 48 | let :params do { 49 | :add_field => { 'field1' => 'value1' }, 50 | :add_tag => ['value2'], 51 | :clones => ['value3'], 52 | :exclude_tags => ['value4'], 53 | :remove_tag => ['value5'], 54 | :tags => ['value6'], 55 | :type => 'value7', 56 | } end 57 | 58 | it { should contain_file('/etc/logstash/agent/config/filter_10_clone_test').with(:owner => 'logstash', :group => 'logstash') } 59 | 60 | end 61 | 62 | end 63 | -------------------------------------------------------------------------------- /spec/defines/output/logstash_output_circonus_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::output::circonus', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :annotation => { 'field1' => 'value1' }, 13 | :api_token => 'value2', 14 | :app_name => 'value3', 15 | :exclude_tags => ['value4'], 16 | :fields => ['value5'], 17 | :tags => ['value6'], 18 | :type => 'value7', 19 | } end 20 | 21 | it { should contain_file('/etc/logstash/agent/config/output_circonus_test').with(:content => "output {\n circonus {\n annotation => [\"field1\", \"value1\"]\n api_token => \"value2\"\n app_name => \"value3\"\n exclude_tags => ['value4']\n fields => ['value5']\n tags => ['value6']\n type => \"value7\"\n }\n}\n") } 22 | end 23 | 24 | context "Instance test" do 25 | 26 | let :params do { 27 | :annotation => { 'field1' => 'value1' }, 28 | :api_token => 'value2', 29 | :app_name => 'value3', 30 | :exclude_tags => ['value4'], 31 | :fields => ['value5'], 32 | :tags => ['value6'], 33 | :type => 'value7', 34 | :instances => [ 'agent1', 'agent2' ] 35 | } end 36 | 37 | it { should contain_file('/etc/logstash/agent1/config/output_circonus_test') } 38 | it { should contain_file('/etc/logstash/agent2/config/output_circonus_test') } 39 | 40 | end 41 | 42 | context "Set file owner" do 43 | 44 | let(:facts) { {:operatingsystem => 'CentOS' }} 45 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 46 | let(:title) { 'test' } 47 | 48 | let :params do { 49 | :annotation => { 'field1' => 'value1' }, 50 | :api_token => 'value2', 51 | :app_name => 'value3', 52 | :exclude_tags => ['value4'], 53 | :fields => ['value5'], 54 | :tags => ['value6'], 55 | :type => 'value7', 56 | } end 57 | 58 | it { should contain_file('/etc/logstash/agent/config/output_circonus_test').with(:owner => 'logstash', :group => 'logstash') } 59 | 60 | end 61 | 62 | end 63 | -------------------------------------------------------------------------------- /spec/defines/input/logstash_input_heroku_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::input::heroku', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :app => 'value2', 14 | :charset => 'ASCII-8BIT', 15 | :debug => false, 16 | :format => 'plain', 17 | :message_format => 'value6', 18 | :tags => ['value7'], 19 | :type => 'value8', 20 | } end 21 | 22 | it { should contain_file('/etc/logstash/agent/config/input_heroku_test').with(:content => "input {\n heroku {\n add_field => [\"field1\", \"value1\"]\n app => \"value2\"\n charset => \"ASCII-8BIT\"\n debug => false\n format => \"plain\"\n message_format => \"value6\"\n tags => ['value7']\n type => \"value8\"\n }\n}\n") } 23 | end 24 | 25 | context "Instance test" do 26 | 27 | let :params do { 28 | :add_field => { 'field1' => 'value1' }, 29 | :app => 'value2', 30 | :charset => 'ASCII-8BIT', 31 | :debug => false, 32 | :format => 'plain', 33 | :message_format => 'value6', 34 | :tags => ['value7'], 35 | :type => 'value8', 36 | :instances => [ 'agent1', 'agent2' ] 37 | } end 38 | 39 | it { should contain_file('/etc/logstash/agent1/config/input_heroku_test') } 40 | it { should contain_file('/etc/logstash/agent2/config/input_heroku_test') } 41 | 42 | end 43 | 44 | context "Set file owner" do 45 | 46 | let(:facts) { {:operatingsystem => 'CentOS' }} 47 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 48 | let(:title) { 'test' } 49 | 50 | let :params do { 51 | :add_field => { 'field1' => 'value1' }, 52 | :app => 'value2', 53 | :charset => 'ASCII-8BIT', 54 | :debug => false, 55 | :format => 'plain', 56 | :message_format => 'value6', 57 | :tags => ['value7'], 58 | :type => 'value8', 59 | } end 60 | 61 | it { should contain_file('/etc/logstash/agent/config/input_heroku_test').with(:owner => 'logstash', :group => 'logstash') } 62 | 63 | end 64 | 65 | end 66 | -------------------------------------------------------------------------------- /spec/defines/input/logstash_input_pipe_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::input::pipe', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :charset => 'ASCII-8BIT', 14 | :command => 'value3', 15 | :debug => false, 16 | :format => 'plain', 17 | :message_format => 'value6', 18 | :tags => ['value7'], 19 | :type => 'value8', 20 | } end 21 | 22 | it { should contain_file('/etc/logstash/agent/config/input_pipe_test').with(:content => "input {\n pipe {\n add_field => [\"field1\", \"value1\"]\n charset => \"ASCII-8BIT\"\n command => \"value3\"\n debug => false\n format => \"plain\"\n message_format => \"value6\"\n tags => ['value7']\n type => \"value8\"\n }\n}\n") } 23 | end 24 | 25 | context "Instance test" do 26 | 27 | let :params do { 28 | :add_field => { 'field1' => 'value1' }, 29 | :charset => 'ASCII-8BIT', 30 | :command => 'value3', 31 | :debug => false, 32 | :format => 'plain', 33 | :message_format => 'value6', 34 | :tags => ['value7'], 35 | :type => 'value8', 36 | :instances => [ 'agent1', 'agent2' ] 37 | } end 38 | 39 | it { should contain_file('/etc/logstash/agent1/config/input_pipe_test') } 40 | it { should contain_file('/etc/logstash/agent2/config/input_pipe_test') } 41 | 42 | end 43 | 44 | context "Set file owner" do 45 | 46 | let(:facts) { {:operatingsystem => 'CentOS' }} 47 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 48 | let(:title) { 'test' } 49 | 50 | let :params do { 51 | :add_field => { 'field1' => 'value1' }, 52 | :charset => 'ASCII-8BIT', 53 | :command => 'value3', 54 | :debug => false, 55 | :format => 'plain', 56 | :message_format => 'value6', 57 | :tags => ['value7'], 58 | :type => 'value8', 59 | } end 60 | 61 | it { should contain_file('/etc/logstash/agent/config/input_pipe_test').with(:owner => 'logstash', :group => 'logstash') } 62 | 63 | end 64 | 65 | end 66 | -------------------------------------------------------------------------------- /spec/defines/input/logstash_input_varnishlog_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::input::varnishlog', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :charset => 'ASCII-8BIT', 14 | :debug => false, 15 | :format => 'plain', 16 | :message_format => 'value5', 17 | :tags => ['value6'], 18 | :threads => 7, 19 | :type => 'value8', 20 | } end 21 | 22 | it { should contain_file('/etc/logstash/agent/config/input_varnishlog_test').with(:content => "input {\n varnishlog {\n add_field => [\"field1\", \"value1\"]\n charset => \"ASCII-8BIT\"\n debug => false\n format => \"plain\"\n message_format => \"value5\"\n tags => ['value6']\n threads => 7\n type => \"value8\"\n }\n}\n") } 23 | end 24 | 25 | context "Instance test" do 26 | 27 | let :params do { 28 | :add_field => { 'field1' => 'value1' }, 29 | :charset => 'ASCII-8BIT', 30 | :debug => false, 31 | :format => 'plain', 32 | :message_format => 'value5', 33 | :tags => ['value6'], 34 | :threads => 7, 35 | :type => 'value8', 36 | :instances => [ 'agent1', 'agent2' ] 37 | } end 38 | 39 | it { should contain_file('/etc/logstash/agent1/config/input_varnishlog_test') } 40 | it { should contain_file('/etc/logstash/agent2/config/input_varnishlog_test') } 41 | 42 | end 43 | 44 | context "Set file owner" do 45 | 46 | let(:facts) { {:operatingsystem => 'CentOS' }} 47 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 48 | let(:title) { 'test' } 49 | 50 | let :params do { 51 | :add_field => { 'field1' => 'value1' }, 52 | :charset => 'ASCII-8BIT', 53 | :debug => false, 54 | :format => 'plain', 55 | :message_format => 'value5', 56 | :tags => ['value6'], 57 | :threads => 7, 58 | :type => 'value8', 59 | } end 60 | 61 | it { should contain_file('/etc/logstash/agent/config/input_varnishlog_test').with(:owner => 'logstash', :group => 'logstash') } 62 | 63 | end 64 | 65 | end 66 | -------------------------------------------------------------------------------- /spec/defines/input/logstash_input_eventlog_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::input::eventlog', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :charset => 'ASCII-8BIT', 14 | :debug => false, 15 | :format => 'plain', 16 | :logfile => 'value5', 17 | :message_format => 'value6', 18 | :tags => ['value7'], 19 | :type => 'value8', 20 | } end 21 | 22 | it { should contain_file('/etc/logstash/agent/config/input_eventlog_test').with(:content => "input {\n eventlog {\n add_field => [\"field1\", \"value1\"]\n charset => \"ASCII-8BIT\"\n debug => false\n format => \"plain\"\n logfile => \"value5\"\n message_format => \"value6\"\n tags => ['value7']\n type => \"value8\"\n }\n}\n") } 23 | end 24 | 25 | context "Instance test" do 26 | 27 | let :params do { 28 | :add_field => { 'field1' => 'value1' }, 29 | :charset => 'ASCII-8BIT', 30 | :debug => false, 31 | :format => 'plain', 32 | :logfile => 'value5', 33 | :message_format => 'value6', 34 | :tags => ['value7'], 35 | :type => 'value8', 36 | :instances => [ 'agent1', 'agent2' ] 37 | } end 38 | 39 | it { should contain_file('/etc/logstash/agent1/config/input_eventlog_test') } 40 | it { should contain_file('/etc/logstash/agent2/config/input_eventlog_test') } 41 | 42 | end 43 | 44 | context "Set file owner" do 45 | 46 | let(:facts) { {:operatingsystem => 'CentOS' }} 47 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 48 | let(:title) { 'test' } 49 | 50 | let :params do { 51 | :add_field => { 'field1' => 'value1' }, 52 | :charset => 'ASCII-8BIT', 53 | :debug => false, 54 | :format => 'plain', 55 | :logfile => 'value5', 56 | :message_format => 'value6', 57 | :tags => ['value7'], 58 | :type => 'value8', 59 | } end 60 | 61 | it { should contain_file('/etc/logstash/agent/config/input_eventlog_test').with(:owner => 'logstash', :group => 'logstash') } 62 | 63 | end 64 | 65 | end 66 | -------------------------------------------------------------------------------- /manifests/config.pp: -------------------------------------------------------------------------------- 1 | # == Class: logstash::config 2 | # 3 | # This class exists to coordinate all configuration related actions, 4 | # functionality and logical units in a central place. 5 | # 6 | # 7 | # === Parameters 8 | # 9 | # This class does not provide any parameters. 10 | # 11 | # 12 | # === Examples 13 | # 14 | # This class may be imported by other classes to use its functionality: 15 | # class { 'logstash::config': } 16 | # 17 | # It is not intended to be used directly by external resources like node 18 | # definitions or other modules. 19 | # 20 | # 21 | # === Authors 22 | # 23 | # * Richard Pijnenburg 24 | # 25 | class logstash::config { 26 | 27 | File { 28 | owner => $logstash::logstash_user, 29 | group => $logstash::logstash_group 30 | } 31 | 32 | # make sure he config dir exists 33 | file { $logstash::configdir: 34 | ensure => directory, 35 | mode => '0644' 36 | } 37 | 38 | if $logstash::multi_instance == true { 39 | 40 | # Setup and manage config dirs for the instances 41 | logstash::configdir { $logstash::instances:; } 42 | 43 | } else { 44 | 45 | # Manage the single config dir 46 | file { "${logstash::configdir}/conf.d": 47 | ensure => directory, 48 | mode => '0640', 49 | purge => true, 50 | recurse => true, 51 | notify => Service['logstash'], 52 | require => File[$logstash::configdir] 53 | } 54 | 55 | file { "${logstash::configdir}/conf.d/pattern": 56 | ensure => directory, 57 | mode => '0640', 58 | purge => true, 59 | recurse => true, 60 | notify => Service['logstash'] 61 | } 62 | 63 | if $logstash::conffile { 64 | file { "${logstash::configdir}/conf.d/logstash.config": 65 | ensure => file, 66 | mode => '0440', 67 | source => $logstash::conffile, 68 | } 69 | } 70 | } 71 | 72 | $tmp_dir = "${logstash::installpath}/tmp" 73 | 74 | #### Create the tmp dir 75 | exec { 'create_tmp_dir': 76 | cwd => '/', 77 | path => ['/usr/bin', '/bin'], 78 | command => "mkdir -p ${tmp_dir}", 79 | creates => $tmp_dir; 80 | } 81 | 82 | file { $tmp_dir: 83 | ensure => directory, 84 | mode => '0640', 85 | require => Exec[ 'create_tmp_dir' ] 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /spec/defines/filter/logstash_filter_ruby_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::filter::ruby', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :add_tag => ['value2'], 14 | :code => 'value3', 15 | :exclude_tags => ['value4'], 16 | :init => 'value5', 17 | :remove_tag => ['value6'], 18 | :tags => ['value7'], 19 | :type => 'value8', 20 | } end 21 | 22 | it { should contain_file('/etc/logstash/agent/config/filter_10_ruby_test').with(:content => "filter {\n ruby {\n add_field => [\"field1\", \"value1\"]\n add_tag => ['value2']\n code => \"value3\"\n exclude_tags => ['value4']\n init => \"value5\"\n remove_tag => ['value6']\n tags => ['value7']\n type => \"value8\"\n }\n}\n") } 23 | end 24 | 25 | context "Instance test" do 26 | 27 | let :params do { 28 | :add_field => { 'field1' => 'value1' }, 29 | :add_tag => ['value2'], 30 | :code => 'value3', 31 | :exclude_tags => ['value4'], 32 | :init => 'value5', 33 | :remove_tag => ['value6'], 34 | :tags => ['value7'], 35 | :type => 'value8', 36 | :instances => [ 'agent1', 'agent2' ] 37 | } end 38 | 39 | it { should contain_file('/etc/logstash/agent1/config/filter_10_ruby_test') } 40 | it { should contain_file('/etc/logstash/agent2/config/filter_10_ruby_test') } 41 | 42 | end 43 | 44 | context "Set file owner" do 45 | 46 | let(:facts) { {:operatingsystem => 'CentOS' }} 47 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 48 | let(:title) { 'test' } 49 | 50 | let :params do { 51 | :add_field => { 'field1' => 'value1' }, 52 | :add_tag => ['value2'], 53 | :code => 'value3', 54 | :exclude_tags => ['value4'], 55 | :init => 'value5', 56 | :remove_tag => ['value6'], 57 | :tags => ['value7'], 58 | :type => 'value8', 59 | } end 60 | 61 | it { should contain_file('/etc/logstash/agent/config/filter_10_ruby_test').with(:owner => 'logstash', :group => 'logstash') } 62 | 63 | end 64 | 65 | end 66 | -------------------------------------------------------------------------------- /spec/defines/output/logstash_output_gemfire_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::output::gemfire', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :cache_name => 'value1', 13 | :cache_xml_file => 'value2', 14 | :exclude_tags => ['value3'], 15 | :fields => ['value4'], 16 | :key_format => 'value5', 17 | :region_name => 'value6', 18 | :tags => ['value7'], 19 | :type => 'value8', 20 | } end 21 | 22 | it { should contain_file('/etc/logstash/agent/config/output_gemfire_test').with(:content => "output {\n gemfire {\n cache_name => \"value1\"\n cache_xml_file => \"value2\"\n exclude_tags => ['value3']\n fields => ['value4']\n key_format => \"value5\"\n region_name => \"value6\"\n tags => ['value7']\n type => \"value8\"\n }\n}\n") } 23 | end 24 | 25 | context "Instance test" do 26 | 27 | let :params do { 28 | :cache_name => 'value1', 29 | :cache_xml_file => 'value2', 30 | :exclude_tags => ['value3'], 31 | :fields => ['value4'], 32 | :key_format => 'value5', 33 | :region_name => 'value6', 34 | :tags => ['value7'], 35 | :type => 'value8', 36 | :instances => [ 'agent1', 'agent2' ] 37 | } end 38 | 39 | it { should contain_file('/etc/logstash/agent1/config/output_gemfire_test') } 40 | it { should contain_file('/etc/logstash/agent2/config/output_gemfire_test') } 41 | 42 | end 43 | 44 | context "Set file owner" do 45 | 46 | let(:facts) { {:operatingsystem => 'CentOS' }} 47 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 48 | let(:title) { 'test' } 49 | 50 | let :params do { 51 | :cache_name => 'value1', 52 | :cache_xml_file => 'value2', 53 | :exclude_tags => ['value3'], 54 | :fields => ['value4'], 55 | :key_format => 'value5', 56 | :region_name => 'value6', 57 | :tags => ['value7'], 58 | :type => 'value8', 59 | } end 60 | 61 | it { should contain_file('/etc/logstash/agent/config/output_gemfire_test').with(:owner => 'logstash', :group => 'logstash') } 62 | 63 | end 64 | 65 | end 66 | -------------------------------------------------------------------------------- /spec/defines/filter/logstash_filter_date_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::filter::date', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :add_tag => ['value2'], 14 | :exclude_tags => ['value3'], 15 | :locale => 'value4', 16 | :match => ['value5'], 17 | :remove_tag => ['value6'], 18 | :tags => ['value7'], 19 | :type => 'value8', 20 | } end 21 | 22 | it { should contain_file('/etc/logstash/agent/config/filter_10_date_test').with(:content => "filter {\n date {\n add_field => [\"field1\", \"value1\"]\n add_tag => ['value2']\n exclude_tags => ['value3']\n locale => \"value4\"\n match => ['value5']\n remove_tag => ['value6']\n tags => ['value7']\n type => \"value8\"\n }\n}\n") } 23 | end 24 | 25 | context "Instance test" do 26 | 27 | let :params do { 28 | :add_field => { 'field1' => 'value1' }, 29 | :add_tag => ['value2'], 30 | :exclude_tags => ['value3'], 31 | :locale => 'value4', 32 | :match => ['value5'], 33 | :remove_tag => ['value6'], 34 | :tags => ['value7'], 35 | :type => 'value8', 36 | :instances => [ 'agent1', 'agent2' ] 37 | } end 38 | 39 | it { should contain_file('/etc/logstash/agent1/config/filter_10_date_test') } 40 | it { should contain_file('/etc/logstash/agent2/config/filter_10_date_test') } 41 | 42 | end 43 | 44 | context "Set file owner" do 45 | 46 | let(:facts) { {:operatingsystem => 'CentOS' }} 47 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 48 | let(:title) { 'test' } 49 | 50 | let :params do { 51 | :add_field => { 'field1' => 'value1' }, 52 | :add_tag => ['value2'], 53 | :exclude_tags => ['value3'], 54 | :locale => 'value4', 55 | :match => ['value5'], 56 | :remove_tag => ['value6'], 57 | :tags => ['value7'], 58 | :type => 'value8', 59 | } end 60 | 61 | it { should contain_file('/etc/logstash/agent/config/filter_10_date_test').with(:owner => 'logstash', :group => 'logstash') } 62 | 63 | end 64 | 65 | end 66 | -------------------------------------------------------------------------------- /spec/defines/filter/logstash_filter_json_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::filter::json', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :add_tag => ['value2'], 14 | :exclude_tags => ['value3'], 15 | :remove_tag => ['value4'], 16 | :source => 'value5', 17 | :tags => ['value6'], 18 | :target => 'value7', 19 | :type => 'value8', 20 | } end 21 | 22 | it { should contain_file('/etc/logstash/agent/config/filter_10_json_test').with(:content => "filter {\n json {\n add_field => [\"field1\", \"value1\"]\n add_tag => ['value2']\n exclude_tags => ['value3']\n remove_tag => ['value4']\n source => \"value5\"\n tags => ['value6']\n target => \"value7\"\n type => \"value8\"\n }\n}\n") } 23 | end 24 | 25 | context "Instance test" do 26 | 27 | let :params do { 28 | :add_field => { 'field1' => 'value1' }, 29 | :add_tag => ['value2'], 30 | :exclude_tags => ['value3'], 31 | :remove_tag => ['value4'], 32 | :source => 'value5', 33 | :tags => ['value6'], 34 | :target => 'value7', 35 | :type => 'value8', 36 | :instances => [ 'agent1', 'agent2' ] 37 | } end 38 | 39 | it { should contain_file('/etc/logstash/agent1/config/filter_10_json_test') } 40 | it { should contain_file('/etc/logstash/agent2/config/filter_10_json_test') } 41 | 42 | end 43 | 44 | context "Set file owner" do 45 | 46 | let(:facts) { {:operatingsystem => 'CentOS' }} 47 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 48 | let(:title) { 'test' } 49 | 50 | let :params do { 51 | :add_field => { 'field1' => 'value1' }, 52 | :add_tag => ['value2'], 53 | :exclude_tags => ['value3'], 54 | :remove_tag => ['value4'], 55 | :source => 'value5', 56 | :tags => ['value6'], 57 | :target => 'value7', 58 | :type => 'value8', 59 | } end 60 | 61 | it { should contain_file('/etc/logstash/agent/config/filter_10_json_test').with(:owner => 'logstash', :group => 'logstash') } 62 | 63 | end 64 | 65 | end 66 | -------------------------------------------------------------------------------- /spec/defines/filter/logstash_filter_split_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::filter::split', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :add_tag => ['value2'], 14 | :exclude_tags => ['value3'], 15 | :field => 'value4', 16 | :remove_tag => ['value5'], 17 | :tags => ['value6'], 18 | :terminator => 'value7', 19 | :type => 'value8', 20 | } end 21 | 22 | it { should contain_file('/etc/logstash/agent/config/filter_10_split_test').with(:content => "filter {\n split {\n add_field => [\"field1\", \"value1\"]\n add_tag => ['value2']\n exclude_tags => ['value3']\n field => \"value4\"\n remove_tag => ['value5']\n tags => ['value6']\n terminator => \"value7\"\n type => \"value8\"\n }\n}\n") } 23 | end 24 | 25 | context "Instance test" do 26 | 27 | let :params do { 28 | :add_field => { 'field1' => 'value1' }, 29 | :add_tag => ['value2'], 30 | :exclude_tags => ['value3'], 31 | :field => 'value4', 32 | :remove_tag => ['value5'], 33 | :tags => ['value6'], 34 | :terminator => 'value7', 35 | :type => 'value8', 36 | :instances => [ 'agent1', 'agent2' ] 37 | } end 38 | 39 | it { should contain_file('/etc/logstash/agent1/config/filter_10_split_test') } 40 | it { should contain_file('/etc/logstash/agent2/config/filter_10_split_test') } 41 | 42 | end 43 | 44 | context "Set file owner" do 45 | 46 | let(:facts) { {:operatingsystem => 'CentOS' }} 47 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 48 | let(:title) { 'test' } 49 | 50 | let :params do { 51 | :add_field => { 'field1' => 'value1' }, 52 | :add_tag => ['value2'], 53 | :exclude_tags => ['value3'], 54 | :field => 'value4', 55 | :remove_tag => ['value5'], 56 | :tags => ['value6'], 57 | :terminator => 'value7', 58 | :type => 'value8', 59 | } end 60 | 61 | it { should contain_file('/etc/logstash/agent/config/filter_10_split_test').with(:owner => 'logstash', :group => 'logstash') } 62 | 63 | end 64 | 65 | end 66 | -------------------------------------------------------------------------------- /spec/defines/input/logstash_input_relp_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::input::relp', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :charset => 'ASCII-8BIT', 14 | :debug => false, 15 | :format => 'plain', 16 | :host => 'value5', 17 | :message_format => 'value6', 18 | :port => 7, 19 | :tags => ['value8'], 20 | :type => 'value9', 21 | } end 22 | 23 | it { should contain_file('/etc/logstash/agent/config/input_relp_test').with(:content => "input {\n relp {\n add_field => [\"field1\", \"value1\"]\n charset => \"ASCII-8BIT\"\n debug => false\n format => \"plain\"\n host => \"value5\"\n message_format => \"value6\"\n port => 7\n tags => ['value8']\n type => \"value9\"\n }\n}\n") } 24 | end 25 | 26 | context "Instance test" do 27 | 28 | let :params do { 29 | :add_field => { 'field1' => 'value1' }, 30 | :charset => 'ASCII-8BIT', 31 | :debug => false, 32 | :format => 'plain', 33 | :host => 'value5', 34 | :message_format => 'value6', 35 | :port => 7, 36 | :tags => ['value8'], 37 | :type => 'value9', 38 | :instances => [ 'agent1', 'agent2' ] 39 | } end 40 | 41 | it { should contain_file('/etc/logstash/agent1/config/input_relp_test') } 42 | it { should contain_file('/etc/logstash/agent2/config/input_relp_test') } 43 | 44 | end 45 | 46 | context "Set file owner" do 47 | 48 | let(:facts) { {:operatingsystem => 'CentOS' }} 49 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 50 | let(:title) { 'test' } 51 | 52 | let :params do { 53 | :add_field => { 'field1' => 'value1' }, 54 | :charset => 'ASCII-8BIT', 55 | :debug => false, 56 | :format => 'plain', 57 | :host => 'value5', 58 | :message_format => 'value6', 59 | :port => 7, 60 | :tags => ['value8'], 61 | :type => 'value9', 62 | } end 63 | 64 | it { should contain_file('/etc/logstash/agent/config/input_relp_test').with(:owner => 'logstash', :group => 'logstash') } 65 | 66 | end 67 | 68 | end 69 | -------------------------------------------------------------------------------- /spec/defines/output/logstash_output_file_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::output::file', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :exclude_tags => ['value1'], 13 | :fields => ['value2'], 14 | :flush_interval => 3, 15 | :gzip => false, 16 | :max_size => 'value5', 17 | :message_format => 'value6', 18 | :path => 'value7', 19 | :tags => ['value8'], 20 | :type => 'value9', 21 | } end 22 | 23 | it { should contain_file('/etc/logstash/agent/config/output_file_test').with(:content => "output {\n file {\n exclude_tags => ['value1']\n fields => ['value2']\n flush_interval => 3\n gzip => false\n max_size => \"value5\"\n message_format => \"value6\"\n path => \"value7\"\n tags => ['value8']\n type => \"value9\"\n }\n}\n") } 24 | end 25 | 26 | context "Instance test" do 27 | 28 | let :params do { 29 | :exclude_tags => ['value1'], 30 | :fields => ['value2'], 31 | :flush_interval => 3, 32 | :gzip => false, 33 | :max_size => 'value5', 34 | :message_format => 'value6', 35 | :path => 'value7', 36 | :tags => ['value8'], 37 | :type => 'value9', 38 | :instances => [ 'agent1', 'agent2' ] 39 | } end 40 | 41 | it { should contain_file('/etc/logstash/agent1/config/output_file_test') } 42 | it { should contain_file('/etc/logstash/agent2/config/output_file_test') } 43 | 44 | end 45 | 46 | context "Set file owner" do 47 | 48 | let(:facts) { {:operatingsystem => 'CentOS' }} 49 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 50 | let(:title) { 'test' } 51 | 52 | let :params do { 53 | :exclude_tags => ['value1'], 54 | :fields => ['value2'], 55 | :flush_interval => 3, 56 | :gzip => false, 57 | :max_size => 'value5', 58 | :message_format => 'value6', 59 | :path => 'value7', 60 | :tags => ['value8'], 61 | :type => 'value9', 62 | } end 63 | 64 | it { should contain_file('/etc/logstash/agent/config/output_file_test').with(:owner => 'logstash', :group => 'logstash') } 65 | 66 | end 67 | 68 | end 69 | -------------------------------------------------------------------------------- /spec/defines/filter/logstash_filter_checksum_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::filter::checksum', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :add_tag => ['value2'], 14 | :algorithm => 'md5', 15 | :exclude_tags => ['value4'], 16 | :keys => ['value5'], 17 | :remove_tag => ['value6'], 18 | :tags => ['value7'], 19 | :type => 'value8', 20 | } end 21 | 22 | it { should contain_file('/etc/logstash/agent/config/filter_10_checksum_test').with(:content => "filter {\n checksum {\n add_field => [\"field1\", \"value1\"]\n add_tag => ['value2']\n algorithm => \"md5\"\n exclude_tags => ['value4']\n keys => ['value5']\n remove_tag => ['value6']\n tags => ['value7']\n type => \"value8\"\n }\n}\n") } 23 | end 24 | 25 | context "Instance test" do 26 | 27 | let :params do { 28 | :add_field => { 'field1' => 'value1' }, 29 | :add_tag => ['value2'], 30 | :algorithm => 'md5', 31 | :exclude_tags => ['value4'], 32 | :keys => ['value5'], 33 | :remove_tag => ['value6'], 34 | :tags => ['value7'], 35 | :type => 'value8', 36 | :instances => [ 'agent1', 'agent2' ] 37 | } end 38 | 39 | it { should contain_file('/etc/logstash/agent1/config/filter_10_checksum_test') } 40 | it { should contain_file('/etc/logstash/agent2/config/filter_10_checksum_test') } 41 | 42 | end 43 | 44 | context "Set file owner" do 45 | 46 | let(:facts) { {:operatingsystem => 'CentOS' }} 47 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 48 | let(:title) { 'test' } 49 | 50 | let :params do { 51 | :add_field => { 'field1' => 'value1' }, 52 | :add_tag => ['value2'], 53 | :algorithm => 'md5', 54 | :exclude_tags => ['value4'], 55 | :keys => ['value5'], 56 | :remove_tag => ['value6'], 57 | :tags => ['value7'], 58 | :type => 'value8', 59 | } end 60 | 61 | it { should contain_file('/etc/logstash/agent/config/filter_10_checksum_test').with(:owner => 'logstash', :group => 'logstash') } 62 | 63 | end 64 | 65 | end 66 | -------------------------------------------------------------------------------- /spec/defines/filter/logstash_filter_urldecode_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::filter::urldecode', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :add_tag => ['value2'], 14 | :all_fields => false, 15 | :exclude_tags => ['value4'], 16 | :field => 'value5', 17 | :remove_tag => ['value6'], 18 | :tags => ['value7'], 19 | :type => 'value8', 20 | } end 21 | 22 | it { should contain_file('/etc/logstash/agent/config/filter_10_urldecode_test').with(:content => "filter {\n urldecode {\n add_field => [\"field1\", \"value1\"]\n add_tag => ['value2']\n all_fields => false\n exclude_tags => ['value4']\n field => \"value5\"\n remove_tag => ['value6']\n tags => ['value7']\n type => \"value8\"\n }\n}\n") } 23 | end 24 | 25 | context "Instance test" do 26 | 27 | let :params do { 28 | :add_field => { 'field1' => 'value1' }, 29 | :add_tag => ['value2'], 30 | :all_fields => false, 31 | :exclude_tags => ['value4'], 32 | :field => 'value5', 33 | :remove_tag => ['value6'], 34 | :tags => ['value7'], 35 | :type => 'value8', 36 | :instances => [ 'agent1', 'agent2' ] 37 | } end 38 | 39 | it { should contain_file('/etc/logstash/agent1/config/filter_10_urldecode_test') } 40 | it { should contain_file('/etc/logstash/agent2/config/filter_10_urldecode_test') } 41 | 42 | end 43 | 44 | context "Set file owner" do 45 | 46 | let(:facts) { {:operatingsystem => 'CentOS' }} 47 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 48 | let(:title) { 'test' } 49 | 50 | let :params do { 51 | :add_field => { 'field1' => 'value1' }, 52 | :add_tag => ['value2'], 53 | :all_fields => false, 54 | :exclude_tags => ['value4'], 55 | :field => 'value5', 56 | :remove_tag => ['value6'], 57 | :tags => ['value7'], 58 | :type => 'value8', 59 | } end 60 | 61 | it { should contain_file('/etc/logstash/agent/config/filter_10_urldecode_test').with(:owner => 'logstash', :group => 'logstash') } 62 | 63 | end 64 | 65 | end 66 | -------------------------------------------------------------------------------- /spec/defines/filter/logstash_filter_environment_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::filter::environment', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :add_field_from_env => { 'field2' => 'value2' }, 14 | :add_tag => ['value3'], 15 | :exclude_tags => ['value4'], 16 | :remove_tag => ['value5'], 17 | :tags => ['value6'], 18 | :type => 'value7', 19 | } end 20 | 21 | it { should contain_file('/etc/logstash/agent/config/filter_10_environment_test').with(:content => "filter {\n environment {\n add_field => [\"field1\", \"value1\"]\n add_field_from_env => [\"field2\", \"value2\"]\n add_tag => ['value3']\n exclude_tags => ['value4']\n remove_tag => ['value5']\n tags => ['value6']\n type => \"value7\"\n }\n}\n") } 22 | end 23 | 24 | context "Instance test" do 25 | 26 | let :params do { 27 | :add_field => { 'field1' => 'value1' }, 28 | :add_field_from_env => { 'field2' => 'value2' }, 29 | :add_tag => ['value3'], 30 | :exclude_tags => ['value4'], 31 | :remove_tag => ['value5'], 32 | :tags => ['value6'], 33 | :type => 'value7', 34 | :instances => [ 'agent1', 'agent2' ] 35 | } end 36 | 37 | it { should contain_file('/etc/logstash/agent1/config/filter_10_environment_test') } 38 | it { should contain_file('/etc/logstash/agent2/config/filter_10_environment_test') } 39 | 40 | end 41 | 42 | context "Set file owner" do 43 | 44 | let(:facts) { {:operatingsystem => 'CentOS' }} 45 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 46 | let(:title) { 'test' } 47 | 48 | let :params do { 49 | :add_field => { 'field1' => 'value1' }, 50 | :add_field_from_env => { 'field2' => 'value2' }, 51 | :add_tag => ['value3'], 52 | :exclude_tags => ['value4'], 53 | :remove_tag => ['value5'], 54 | :tags => ['value6'], 55 | :type => 'value7', 56 | } end 57 | 58 | it { should contain_file('/etc/logstash/agent/config/filter_10_environment_test').with(:owner => 'logstash', :group => 'logstash') } 59 | 60 | end 61 | 62 | end 63 | -------------------------------------------------------------------------------- /spec/defines/input/logstash_input_ganglia_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::input::ganglia', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :charset => 'ASCII-8BIT', 14 | :debug => false, 15 | :format => 'plain', 16 | :host => 'value5', 17 | :message_format => 'value6', 18 | :port => 7, 19 | :tags => ['value8'], 20 | :type => 'value9', 21 | } end 22 | 23 | it { should contain_file('/etc/logstash/agent/config/input_ganglia_test').with(:content => "input {\n ganglia {\n add_field => [\"field1\", \"value1\"]\n charset => \"ASCII-8BIT\"\n debug => false\n format => \"plain\"\n host => \"value5\"\n message_format => \"value6\"\n port => 7\n tags => ['value8']\n type => \"value9\"\n }\n}\n") } 24 | end 25 | 26 | context "Instance test" do 27 | 28 | let :params do { 29 | :add_field => { 'field1' => 'value1' }, 30 | :charset => 'ASCII-8BIT', 31 | :debug => false, 32 | :format => 'plain', 33 | :host => 'value5', 34 | :message_format => 'value6', 35 | :port => 7, 36 | :tags => ['value8'], 37 | :type => 'value9', 38 | :instances => [ 'agent1', 'agent2' ] 39 | } end 40 | 41 | it { should contain_file('/etc/logstash/agent1/config/input_ganglia_test') } 42 | it { should contain_file('/etc/logstash/agent2/config/input_ganglia_test') } 43 | 44 | end 45 | 46 | context "Set file owner" do 47 | 48 | let(:facts) { {:operatingsystem => 'CentOS' }} 49 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 50 | let(:title) { 'test' } 51 | 52 | let :params do { 53 | :add_field => { 'field1' => 'value1' }, 54 | :charset => 'ASCII-8BIT', 55 | :debug => false, 56 | :format => 'plain', 57 | :host => 'value5', 58 | :message_format => 'value6', 59 | :port => 7, 60 | :tags => ['value8'], 61 | :type => 'value9', 62 | } end 63 | 64 | it { should contain_file('/etc/logstash/agent/config/input_ganglia_test').with(:owner => 'logstash', :group => 'logstash') } 65 | 66 | end 67 | 68 | end 69 | -------------------------------------------------------------------------------- /spec/defines/input/logstash_input_exec_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::input::exec', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :charset => 'ASCII-8BIT', 14 | :command => 'value3', 15 | :debug => false, 16 | :format => 'plain', 17 | :interval => 6, 18 | :message_format => 'value7', 19 | :tags => ['value8'], 20 | :type => 'value9', 21 | } end 22 | 23 | it { should contain_file('/etc/logstash/agent/config/input_exec_test').with(:content => "input {\n exec {\n add_field => [\"field1\", \"value1\"]\n charset => \"ASCII-8BIT\"\n command => \"value3\"\n debug => false\n format => \"plain\"\n interval => 6\n message_format => \"value7\"\n tags => ['value8']\n type => \"value9\"\n }\n}\n") } 24 | end 25 | 26 | context "Instance test" do 27 | 28 | let :params do { 29 | :add_field => { 'field1' => 'value1' }, 30 | :charset => 'ASCII-8BIT', 31 | :command => 'value3', 32 | :debug => false, 33 | :format => 'plain', 34 | :interval => 6, 35 | :message_format => 'value7', 36 | :tags => ['value8'], 37 | :type => 'value9', 38 | :instances => [ 'agent1', 'agent2' ] 39 | } end 40 | 41 | it { should contain_file('/etc/logstash/agent1/config/input_exec_test') } 42 | it { should contain_file('/etc/logstash/agent2/config/input_exec_test') } 43 | 44 | end 45 | 46 | context "Set file owner" do 47 | 48 | let(:facts) { {:operatingsystem => 'CentOS' }} 49 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 50 | let(:title) { 'test' } 51 | 52 | let :params do { 53 | :add_field => { 'field1' => 'value1' }, 54 | :charset => 'ASCII-8BIT', 55 | :command => 'value3', 56 | :debug => false, 57 | :format => 'plain', 58 | :interval => 6, 59 | :message_format => 'value7', 60 | :tags => ['value8'], 61 | :type => 'value9', 62 | } end 63 | 64 | it { should contain_file('/etc/logstash/agent/config/input_exec_test').with(:owner => 'logstash', :group => 'logstash') } 65 | 66 | end 67 | 68 | end 69 | -------------------------------------------------------------------------------- /spec/defines/input/logstash_input_websocket_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::input::websocket', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :charset => 'ASCII-8BIT', 14 | :debug => false, 15 | :format => 'plain', 16 | :message_format => 'value5', 17 | :mode => 'server', 18 | :tags => ['value7'], 19 | :type => 'value8', 20 | :url => 'value9', 21 | } end 22 | 23 | it { should contain_file('/etc/logstash/agent/config/input_websocket_test').with(:content => "input {\n websocket {\n add_field => [\"field1\", \"value1\"]\n charset => \"ASCII-8BIT\"\n debug => false\n format => \"plain\"\n message_format => \"value5\"\n mode => \"server\"\n tags => ['value7']\n type => \"value8\"\n url => \"value9\"\n }\n}\n") } 24 | end 25 | 26 | context "Instance test" do 27 | 28 | let :params do { 29 | :add_field => { 'field1' => 'value1' }, 30 | :charset => 'ASCII-8BIT', 31 | :debug => false, 32 | :format => 'plain', 33 | :message_format => 'value5', 34 | :mode => 'server', 35 | :tags => ['value7'], 36 | :type => 'value8', 37 | :url => 'value9', 38 | :instances => [ 'agent1', 'agent2' ] 39 | } end 40 | 41 | it { should contain_file('/etc/logstash/agent1/config/input_websocket_test') } 42 | it { should contain_file('/etc/logstash/agent2/config/input_websocket_test') } 43 | 44 | end 45 | 46 | context "Set file owner" do 47 | 48 | let(:facts) { {:operatingsystem => 'CentOS' }} 49 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 50 | let(:title) { 'test' } 51 | 52 | let :params do { 53 | :add_field => { 'field1' => 'value1' }, 54 | :charset => 'ASCII-8BIT', 55 | :debug => false, 56 | :format => 'plain', 57 | :message_format => 'value5', 58 | :mode => 'server', 59 | :tags => ['value7'], 60 | :type => 'value8', 61 | :url => 'value9', 62 | } end 63 | 64 | it { should contain_file('/etc/logstash/agent/config/input_websocket_test').with(:owner => 'logstash', :group => 'logstash') } 65 | 66 | end 67 | 68 | end 69 | -------------------------------------------------------------------------------- /spec/defines/output/logstash_output_stomp_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::output::stomp', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :debug => false, 13 | :destination => 'value2', 14 | :exclude_tags => ['value3'], 15 | :fields => ['value4'], 16 | :host => 'value5', 17 | :password => 'value6', 18 | :port => 7, 19 | :tags => ['value8'], 20 | :type => 'value9', 21 | :user => 'value10', 22 | } end 23 | 24 | it { should contain_file('/etc/logstash/agent/config/output_stomp_test').with(:content => "output {\n stomp {\n debug => false\n destination => \"value2\"\n exclude_tags => ['value3']\n fields => ['value4']\n host => \"value5\"\n password => \"value6\"\n port => 7\n tags => ['value8']\n type => \"value9\"\n user => \"value10\"\n }\n}\n") } 25 | end 26 | 27 | context "Instance test" do 28 | 29 | let :params do { 30 | :debug => false, 31 | :destination => 'value2', 32 | :exclude_tags => ['value3'], 33 | :fields => ['value4'], 34 | :host => 'value5', 35 | :password => 'value6', 36 | :port => 7, 37 | :tags => ['value8'], 38 | :type => 'value9', 39 | :user => 'value10', 40 | :instances => [ 'agent1', 'agent2' ] 41 | } end 42 | 43 | it { should contain_file('/etc/logstash/agent1/config/output_stomp_test') } 44 | it { should contain_file('/etc/logstash/agent2/config/output_stomp_test') } 45 | 46 | end 47 | 48 | context "Set file owner" do 49 | 50 | let(:facts) { {:operatingsystem => 'CentOS' }} 51 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 52 | let(:title) { 'test' } 53 | 54 | let :params do { 55 | :debug => false, 56 | :destination => 'value2', 57 | :exclude_tags => ['value3'], 58 | :fields => ['value4'], 59 | :host => 'value5', 60 | :password => 'value6', 61 | :port => 7, 62 | :tags => ['value8'], 63 | :type => 'value9', 64 | :user => 'value10', 65 | } end 66 | 67 | it { should contain_file('/etc/logstash/agent/config/output_stomp_test').with(:owner => 'logstash', :group => 'logstash') } 68 | 69 | end 70 | 71 | end 72 | -------------------------------------------------------------------------------- /spec/defines/filter/logstash_filter_sleep_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::filter::sleep', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :add_tag => ['value2'], 14 | :every => 'value3', 15 | :exclude_tags => ['value4'], 16 | :remove_tag => ['value5'], 17 | :replay => false, 18 | :tags => ['value7'], 19 | :time => 'value8', 20 | :type => 'value9', 21 | } end 22 | 23 | it { should contain_file('/etc/logstash/agent/config/filter_10_sleep_test').with(:content => "filter {\n sleep {\n add_field => [\"field1\", \"value1\"]\n add_tag => ['value2']\n every => \"value3\"\n exclude_tags => ['value4']\n remove_tag => ['value5']\n replay => false\n tags => ['value7']\n time => \"value8\"\n type => \"value9\"\n }\n}\n") } 24 | end 25 | 26 | context "Instance test" do 27 | 28 | let :params do { 29 | :add_field => { 'field1' => 'value1' }, 30 | :add_tag => ['value2'], 31 | :every => 'value3', 32 | :exclude_tags => ['value4'], 33 | :remove_tag => ['value5'], 34 | :replay => false, 35 | :tags => ['value7'], 36 | :time => 'value8', 37 | :type => 'value9', 38 | :instances => [ 'agent1', 'agent2' ] 39 | } end 40 | 41 | it { should contain_file('/etc/logstash/agent1/config/filter_10_sleep_test') } 42 | it { should contain_file('/etc/logstash/agent2/config/filter_10_sleep_test') } 43 | 44 | end 45 | 46 | context "Set file owner" do 47 | 48 | let(:facts) { {:operatingsystem => 'CentOS' }} 49 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 50 | let(:title) { 'test' } 51 | 52 | let :params do { 53 | :add_field => { 'field1' => 'value1' }, 54 | :add_tag => ['value2'], 55 | :every => 'value3', 56 | :exclude_tags => ['value4'], 57 | :remove_tag => ['value5'], 58 | :replay => false, 59 | :tags => ['value7'], 60 | :time => 'value8', 61 | :type => 'value9', 62 | } end 63 | 64 | it { should contain_file('/etc/logstash/agent/config/filter_10_sleep_test').with(:owner => 'logstash', :group => 'logstash') } 65 | 66 | end 67 | 68 | end 69 | -------------------------------------------------------------------------------- /spec/defines/output/logstash_output_zeromq_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::output::zeromq', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :address => ['value1'], 13 | :exclude_tags => ['value2'], 14 | :fields => ['value3'], 15 | :mode => 'server', 16 | :sockopt => { 'field5' => 'value5' }, 17 | :tags => ['value6'], 18 | :topic => 'value7', 19 | :topology => 'pushpull', 20 | :type => 'value9', 21 | } end 22 | 23 | it { should contain_file('/etc/logstash/agent/config/output_zeromq_test').with(:content => "output {\n zeromq {\n address => ['value1']\n exclude_tags => ['value2']\n fields => ['value3']\n mode => \"server\"\n sockopt => [\"field5\", \"value5\"]\n tags => ['value6']\n topic => \"value7\"\n topology => \"pushpull\"\n type => \"value9\"\n }\n}\n") } 24 | end 25 | 26 | context "Instance test" do 27 | 28 | let :params do { 29 | :address => ['value1'], 30 | :exclude_tags => ['value2'], 31 | :fields => ['value3'], 32 | :mode => 'server', 33 | :sockopt => { 'field5' => 'value5' }, 34 | :tags => ['value6'], 35 | :topic => 'value7', 36 | :topology => 'pushpull', 37 | :type => 'value9', 38 | :instances => [ 'agent1', 'agent2' ] 39 | } end 40 | 41 | it { should contain_file('/etc/logstash/agent1/config/output_zeromq_test') } 42 | it { should contain_file('/etc/logstash/agent2/config/output_zeromq_test') } 43 | 44 | end 45 | 46 | context "Set file owner" do 47 | 48 | let(:facts) { {:operatingsystem => 'CentOS' }} 49 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 50 | let(:title) { 'test' } 51 | 52 | let :params do { 53 | :address => ['value1'], 54 | :exclude_tags => ['value2'], 55 | :fields => ['value3'], 56 | :mode => 'server', 57 | :sockopt => { 'field5' => 'value5' }, 58 | :tags => ['value6'], 59 | :topic => 'value7', 60 | :topology => 'pushpull', 61 | :type => 'value9', 62 | } end 63 | 64 | it { should contain_file('/etc/logstash/agent/config/output_zeromq_test').with(:owner => 'logstash', :group => 'logstash') } 65 | 66 | end 67 | 68 | end 69 | -------------------------------------------------------------------------------- /spec/defines/output/logstash_output_nagios_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::output::nagios', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :commandfile => 'puppet:///path/to/file1', 13 | :exclude_tags => ['value2'], 14 | :fields => ['value3'], 15 | :nagios_level => '0', 16 | :tags => ['value5'], 17 | :type => 'value6', 18 | } end 19 | 20 | it { should contain_file('/etc/logstash/agent/config/output_nagios_test').with(:content => "output {\n nagios {\n commandfile => \"/etc/logstash/files/output/nagios/test/file1\"\n exclude_tags => ['value2']\n fields => ['value3']\n nagios_level => \"0\"\n tags => ['value5']\n type => \"value6\"\n }\n}\n") } 21 | it { should contain_file('/etc/logstash/files/output/nagios/test/file1').with(:source => 'puppet:///path/to/file1') } 22 | it { should contain_file('/etc/logstash/files/output/nagios/test') } 23 | it { should contain_exec('create_files_dir_output_nagios_test').with(:command => 'mkdir -p /etc/logstash/files/output/nagios/test') } 24 | end 25 | 26 | context "Instance test" do 27 | 28 | let :params do { 29 | :commandfile => 'puppet:///path/to/file1', 30 | :exclude_tags => ['value2'], 31 | :fields => ['value3'], 32 | :nagios_level => '0', 33 | :tags => ['value5'], 34 | :type => 'value6', 35 | :instances => [ 'agent1', 'agent2' ] 36 | } end 37 | 38 | it { should contain_file('/etc/logstash/agent1/config/output_nagios_test') } 39 | it { should contain_file('/etc/logstash/agent2/config/output_nagios_test') } 40 | 41 | end 42 | 43 | context "Set file owner" do 44 | 45 | let(:facts) { {:operatingsystem => 'CentOS' }} 46 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 47 | let(:title) { 'test' } 48 | 49 | let :params do { 50 | :commandfile => 'puppet:///path/to/file1', 51 | :exclude_tags => ['value2'], 52 | :fields => ['value3'], 53 | :nagios_level => '0', 54 | :tags => ['value5'], 55 | :type => 'value6', 56 | } end 57 | 58 | it { should contain_file('/etc/logstash/agent/config/output_nagios_test').with(:owner => 'logstash', :group => 'logstash') } 59 | 60 | end 61 | 62 | end 63 | -------------------------------------------------------------------------------- /spec/defines/input/logstash_input_gelf_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::input::gelf', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :charset => 'ASCII-8BIT', 14 | :debug => false, 15 | :format => 'plain', 16 | :host => 'value5', 17 | :message_format => 'value6', 18 | :port => 7, 19 | :remap => false, 20 | :tags => ['value9'], 21 | :type => 'value10', 22 | } end 23 | 24 | it { should contain_file('/etc/logstash/agent/config/input_gelf_test').with(:content => "input {\n gelf {\n add_field => [\"field1\", \"value1\"]\n charset => \"ASCII-8BIT\"\n debug => false\n format => \"plain\"\n host => \"value5\"\n message_format => \"value6\"\n port => 7\n remap => false\n tags => ['value9']\n type => \"value10\"\n }\n}\n") } 25 | end 26 | 27 | context "Instance test" do 28 | 29 | let :params do { 30 | :add_field => { 'field1' => 'value1' }, 31 | :charset => 'ASCII-8BIT', 32 | :debug => false, 33 | :format => 'plain', 34 | :host => 'value5', 35 | :message_format => 'value6', 36 | :port => 7, 37 | :remap => false, 38 | :tags => ['value9'], 39 | :type => 'value10', 40 | :instances => [ 'agent1', 'agent2' ] 41 | } end 42 | 43 | it { should contain_file('/etc/logstash/agent1/config/input_gelf_test') } 44 | it { should contain_file('/etc/logstash/agent2/config/input_gelf_test') } 45 | 46 | end 47 | 48 | context "Set file owner" do 49 | 50 | let(:facts) { {:operatingsystem => 'CentOS' }} 51 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 52 | let(:title) { 'test' } 53 | 54 | let :params do { 55 | :add_field => { 'field1' => 'value1' }, 56 | :charset => 'ASCII-8BIT', 57 | :debug => false, 58 | :format => 'plain', 59 | :host => 'value5', 60 | :message_format => 'value6', 61 | :port => 7, 62 | :remap => false, 63 | :tags => ['value9'], 64 | :type => 'value10', 65 | } end 66 | 67 | it { should contain_file('/etc/logstash/agent/config/input_gelf_test').with(:owner => 'logstash', :group => 'logstash') } 68 | 69 | end 70 | 71 | end 72 | -------------------------------------------------------------------------------- /spec/defines/filter/logstash_filter_dns_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::filter::dns', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :action => 'append', 13 | :add_field => { 'field2' => 'value2' }, 14 | :add_tag => ['value3'], 15 | :exclude_tags => ['value4'], 16 | :remove_tag => ['value5'], 17 | :resolve => ['value6'], 18 | :reverse => ['value7'], 19 | :tags => ['value8'], 20 | :type => 'value9', 21 | } end 22 | 23 | it { should contain_file('/etc/logstash/agent/config/filter_10_dns_test').with(:content => "filter {\n dns {\n action => \"append\"\n add_field => [\"field2\", \"value2\"]\n add_tag => ['value3']\n exclude_tags => ['value4']\n remove_tag => ['value5']\n resolve => ['value6']\n reverse => ['value7']\n tags => ['value8']\n type => \"value9\"\n }\n}\n") } 24 | end 25 | 26 | context "Instance test" do 27 | 28 | let :params do { 29 | :action => 'append', 30 | :add_field => { 'field2' => 'value2' }, 31 | :add_tag => ['value3'], 32 | :exclude_tags => ['value4'], 33 | :remove_tag => ['value5'], 34 | :resolve => ['value6'], 35 | :reverse => ['value7'], 36 | :tags => ['value8'], 37 | :type => 'value9', 38 | :instances => [ 'agent1', 'agent2' ] 39 | } end 40 | 41 | it { should contain_file('/etc/logstash/agent1/config/filter_10_dns_test') } 42 | it { should contain_file('/etc/logstash/agent2/config/filter_10_dns_test') } 43 | 44 | end 45 | 46 | context "Set file owner" do 47 | 48 | let(:facts) { {:operatingsystem => 'CentOS' }} 49 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 50 | let(:title) { 'test' } 51 | 52 | let :params do { 53 | :action => 'append', 54 | :add_field => { 'field2' => 'value2' }, 55 | :add_tag => ['value3'], 56 | :exclude_tags => ['value4'], 57 | :remove_tag => ['value5'], 58 | :resolve => ['value6'], 59 | :reverse => ['value7'], 60 | :tags => ['value8'], 61 | :type => 'value9', 62 | } end 63 | 64 | it { should contain_file('/etc/logstash/agent/config/filter_10_dns_test').with(:owner => 'logstash', :group => 'logstash') } 65 | 66 | end 67 | 68 | end 69 | -------------------------------------------------------------------------------- /spec/defines/input/logstash_input_udp_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::input::udp', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :buffer_size => 2, 14 | :charset => 'ASCII-8BIT', 15 | :debug => false, 16 | :format => 'plain', 17 | :host => 'value6', 18 | :message_format => 'value7', 19 | :port => 8, 20 | :tags => ['value9'], 21 | :type => 'value10', 22 | } end 23 | 24 | it { should contain_file('/etc/logstash/agent/config/input_udp_test').with(:content => "input {\n udp {\n add_field => [\"field1\", \"value1\"]\n buffer_size => 2\n charset => \"ASCII-8BIT\"\n debug => false\n format => \"plain\"\n host => \"value6\"\n message_format => \"value7\"\n port => 8\n tags => ['value9']\n type => \"value10\"\n }\n}\n") } 25 | end 26 | 27 | context "Instance test" do 28 | 29 | let :params do { 30 | :add_field => { 'field1' => 'value1' }, 31 | :buffer_size => 2, 32 | :charset => 'ASCII-8BIT', 33 | :debug => false, 34 | :format => 'plain', 35 | :host => 'value6', 36 | :message_format => 'value7', 37 | :port => 8, 38 | :tags => ['value9'], 39 | :type => 'value10', 40 | :instances => [ 'agent1', 'agent2' ] 41 | } end 42 | 43 | it { should contain_file('/etc/logstash/agent1/config/input_udp_test') } 44 | it { should contain_file('/etc/logstash/agent2/config/input_udp_test') } 45 | 46 | end 47 | 48 | context "Set file owner" do 49 | 50 | let(:facts) { {:operatingsystem => 'CentOS' }} 51 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 52 | let(:title) { 'test' } 53 | 54 | let :params do { 55 | :add_field => { 'field1' => 'value1' }, 56 | :buffer_size => 2, 57 | :charset => 'ASCII-8BIT', 58 | :debug => false, 59 | :format => 'plain', 60 | :host => 'value6', 61 | :message_format => 'value7', 62 | :port => 8, 63 | :tags => ['value9'], 64 | :type => 'value10', 65 | } end 66 | 67 | it { should contain_file('/etc/logstash/agent/config/input_udp_test').with(:owner => 'logstash', :group => 'logstash') } 68 | 69 | end 70 | 71 | end 72 | -------------------------------------------------------------------------------- /spec/defines/output/logstash_output_xmpp_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::output::xmpp', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :exclude_tags => ['value1'], 13 | :fields => ['value2'], 14 | :host => 'value3', 15 | :message => 'value4', 16 | :password => 'value5', 17 | :rooms => ['value6'], 18 | :tags => ['value7'], 19 | :type => 'value8', 20 | :user => 'value9', 21 | :users => ['value10'], 22 | } end 23 | 24 | it { should contain_file('/etc/logstash/agent/config/output_xmpp_test').with(:content => "output {\n xmpp {\n exclude_tags => ['value1']\n fields => ['value2']\n host => \"value3\"\n message => \"value4\"\n password => \"value5\"\n rooms => ['value6']\n tags => ['value7']\n type => \"value8\"\n user => \"value9\"\n users => ['value10']\n }\n}\n") } 25 | end 26 | 27 | context "Instance test" do 28 | 29 | let :params do { 30 | :exclude_tags => ['value1'], 31 | :fields => ['value2'], 32 | :host => 'value3', 33 | :message => 'value4', 34 | :password => 'value5', 35 | :rooms => ['value6'], 36 | :tags => ['value7'], 37 | :type => 'value8', 38 | :user => 'value9', 39 | :users => ['value10'], 40 | :instances => [ 'agent1', 'agent2' ] 41 | } end 42 | 43 | it { should contain_file('/etc/logstash/agent1/config/output_xmpp_test') } 44 | it { should contain_file('/etc/logstash/agent2/config/output_xmpp_test') } 45 | 46 | end 47 | 48 | context "Set file owner" do 49 | 50 | let(:facts) { {:operatingsystem => 'CentOS' }} 51 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 52 | let(:title) { 'test' } 53 | 54 | let :params do { 55 | :exclude_tags => ['value1'], 56 | :fields => ['value2'], 57 | :host => 'value3', 58 | :message => 'value4', 59 | :password => 'value5', 60 | :rooms => ['value6'], 61 | :tags => ['value7'], 62 | :type => 'value8', 63 | :user => 'value9', 64 | :users => ['value10'], 65 | } end 66 | 67 | it { should contain_file('/etc/logstash/agent/config/output_xmpp_test').with(:owner => 'logstash', :group => 'logstash') } 68 | 69 | end 70 | 71 | end 72 | -------------------------------------------------------------------------------- /spec/defines/filter/logstash_filter_grep_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::filter::grep', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :add_tag => ['value2'], 14 | :drop => false, 15 | :exclude_tags => ['value4'], 16 | :match => { 'field5' => 'value5' }, 17 | :negate => false, 18 | :remove_tag => ['value7'], 19 | :tags => ['value8'], 20 | :type => 'value9', 21 | } end 22 | 23 | it { should contain_file('/etc/logstash/agent/config/filter_10_grep_test').with(:content => "filter {\n grep {\n add_field => [\"field1\", \"value1\"]\n add_tag => ['value2']\n drop => false\n exclude_tags => ['value4']\n match => [\"field5\", \"value5\"]\n negate => false\n remove_tag => ['value7']\n tags => ['value8']\n type => \"value9\"\n }\n}\n") } 24 | end 25 | 26 | context "Instance test" do 27 | 28 | let :params do { 29 | :add_field => { 'field1' => 'value1' }, 30 | :add_tag => ['value2'], 31 | :drop => false, 32 | :exclude_tags => ['value4'], 33 | :match => { 'field5' => 'value5' }, 34 | :negate => false, 35 | :remove_tag => ['value7'], 36 | :tags => ['value8'], 37 | :type => 'value9', 38 | :instances => [ 'agent1', 'agent2' ] 39 | } end 40 | 41 | it { should contain_file('/etc/logstash/agent1/config/filter_10_grep_test') } 42 | it { should contain_file('/etc/logstash/agent2/config/filter_10_grep_test') } 43 | 44 | end 45 | 46 | context "Set file owner" do 47 | 48 | let(:facts) { {:operatingsystem => 'CentOS' }} 49 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 50 | let(:title) { 'test' } 51 | 52 | let :params do { 53 | :add_field => { 'field1' => 'value1' }, 54 | :add_tag => ['value2'], 55 | :drop => false, 56 | :exclude_tags => ['value4'], 57 | :match => { 'field5' => 'value5' }, 58 | :negate => false, 59 | :remove_tag => ['value7'], 60 | :tags => ['value8'], 61 | :type => 'value9', 62 | } end 63 | 64 | it { should contain_file('/etc/logstash/agent/config/filter_10_grep_test').with(:owner => 'logstash', :group => 'logstash') } 65 | 66 | end 67 | 68 | end 69 | -------------------------------------------------------------------------------- /spec/defines/filter/logstash_filter_anonymize_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::filter::anonymize', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :add_tag => ['value2'], 14 | :algorithm => 'SHA1', 15 | :exclude_tags => ['value4'], 16 | :fields => ['value5'], 17 | :key => 'value6', 18 | :remove_tag => ['value7'], 19 | :tags => ['value8'], 20 | :type => 'value9', 21 | } end 22 | 23 | it { should contain_file('/etc/logstash/agent/config/filter_10_anonymize_test').with(:content => "filter {\n anonymize {\n add_field => [\"field1\", \"value1\"]\n add_tag => ['value2']\n algorithm => \"SHA1\"\n exclude_tags => ['value4']\n fields => ['value5']\n key => \"value6\"\n remove_tag => ['value7']\n tags => ['value8']\n type => \"value9\"\n }\n}\n") } 24 | end 25 | 26 | context "Instance test" do 27 | 28 | let :params do { 29 | :add_field => { 'field1' => 'value1' }, 30 | :add_tag => ['value2'], 31 | :algorithm => 'SHA1', 32 | :exclude_tags => ['value4'], 33 | :fields => ['value5'], 34 | :key => 'value6', 35 | :remove_tag => ['value7'], 36 | :tags => ['value8'], 37 | :type => 'value9', 38 | :instances => [ 'agent1', 'agent2' ] 39 | } end 40 | 41 | it { should contain_file('/etc/logstash/agent1/config/filter_10_anonymize_test') } 42 | it { should contain_file('/etc/logstash/agent2/config/filter_10_anonymize_test') } 43 | 44 | end 45 | 46 | context "Set file owner" do 47 | 48 | let(:facts) { {:operatingsystem => 'CentOS' }} 49 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 50 | let(:title) { 'test' } 51 | 52 | let :params do { 53 | :add_field => { 'field1' => 'value1' }, 54 | :add_tag => ['value2'], 55 | :algorithm => 'SHA1', 56 | :exclude_tags => ['value4'], 57 | :fields => ['value5'], 58 | :key => 'value6', 59 | :remove_tag => ['value7'], 60 | :tags => ['value8'], 61 | :type => 'value9', 62 | } end 63 | 64 | it { should contain_file('/etc/logstash/agent/config/filter_10_anonymize_test').with(:owner => 'logstash', :group => 'logstash') } 65 | 66 | end 67 | 68 | end 69 | -------------------------------------------------------------------------------- /spec/defines/filter/logstash_filter_useragent_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::filter::useragent', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :add_tag => ['value2'], 14 | :exclude_tags => ['value3'], 15 | :regexes => 'value4', 16 | :remove_tag => ['value5'], 17 | :source => 'value6', 18 | :tags => ['value7'], 19 | :target => 'value8', 20 | :type => 'value9', 21 | } end 22 | 23 | it { should contain_file('/etc/logstash/agent/config/filter_10_useragent_test').with(:content => "filter {\n useragent {\n add_field => [\"field1\", \"value1\"]\n add_tag => ['value2']\n exclude_tags => ['value3']\n regexes => \"value4\"\n remove_tag => ['value5']\n source => \"value6\"\n tags => ['value7']\n target => \"value8\"\n type => \"value9\"\n }\n}\n") } 24 | end 25 | 26 | context "Instance test" do 27 | 28 | let :params do { 29 | :add_field => { 'field1' => 'value1' }, 30 | :add_tag => ['value2'], 31 | :exclude_tags => ['value3'], 32 | :regexes => 'value4', 33 | :remove_tag => ['value5'], 34 | :source => 'value6', 35 | :tags => ['value7'], 36 | :target => 'value8', 37 | :type => 'value9', 38 | :instances => [ 'agent1', 'agent2' ] 39 | } end 40 | 41 | it { should contain_file('/etc/logstash/agent1/config/filter_10_useragent_test') } 42 | it { should contain_file('/etc/logstash/agent2/config/filter_10_useragent_test') } 43 | 44 | end 45 | 46 | context "Set file owner" do 47 | 48 | let(:facts) { {:operatingsystem => 'CentOS' }} 49 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 50 | let(:title) { 'test' } 51 | 52 | let :params do { 53 | :add_field => { 'field1' => 'value1' }, 54 | :add_tag => ['value2'], 55 | :exclude_tags => ['value3'], 56 | :regexes => 'value4', 57 | :remove_tag => ['value5'], 58 | :source => 'value6', 59 | :tags => ['value7'], 60 | :target => 'value8', 61 | :type => 'value9', 62 | } end 63 | 64 | it { should contain_file('/etc/logstash/agent/config/filter_10_useragent_test').with(:owner => 'logstash', :group => 'logstash') } 65 | 66 | end 67 | 68 | end 69 | -------------------------------------------------------------------------------- /spec/defines/output/logstash_output_hipchat_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::output::hipchat', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :color => 'value1', 13 | :exclude_tags => ['value2'], 14 | :fields => ['value3'], 15 | :format => 'value4', 16 | :from => 'value5', 17 | :room_id => 'value6', 18 | :tags => ['value7'], 19 | :token => 'value8', 20 | :trigger_notify => false, 21 | :type => 'value10', 22 | } end 23 | 24 | it { should contain_file('/etc/logstash/agent/config/output_hipchat_test').with(:content => "output {\n hipchat {\n color => \"value1\"\n exclude_tags => ['value2']\n fields => ['value3']\n format => \"value4\"\n from => \"value5\"\n room_id => \"value6\"\n tags => ['value7']\n token => \"value8\"\n trigger_notify => false\n type => \"value10\"\n }\n}\n") } 25 | end 26 | 27 | context "Instance test" do 28 | 29 | let :params do { 30 | :color => 'value1', 31 | :exclude_tags => ['value2'], 32 | :fields => ['value3'], 33 | :format => 'value4', 34 | :from => 'value5', 35 | :room_id => 'value6', 36 | :tags => ['value7'], 37 | :token => 'value8', 38 | :trigger_notify => false, 39 | :type => 'value10', 40 | :instances => [ 'agent1', 'agent2' ] 41 | } end 42 | 43 | it { should contain_file('/etc/logstash/agent1/config/output_hipchat_test') } 44 | it { should contain_file('/etc/logstash/agent2/config/output_hipchat_test') } 45 | 46 | end 47 | 48 | context "Set file owner" do 49 | 50 | let(:facts) { {:operatingsystem => 'CentOS' }} 51 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 52 | let(:title) { 'test' } 53 | 54 | let :params do { 55 | :color => 'value1', 56 | :exclude_tags => ['value2'], 57 | :fields => ['value3'], 58 | :format => 'value4', 59 | :from => 'value5', 60 | :room_id => 'value6', 61 | :tags => ['value7'], 62 | :token => 'value8', 63 | :trigger_notify => false, 64 | :type => 'value10', 65 | } end 66 | 67 | it { should contain_file('/etc/logstash/agent/config/output_hipchat_test').with(:owner => 'logstash', :group => 'logstash') } 68 | 69 | end 70 | 71 | end 72 | -------------------------------------------------------------------------------- /spec/defines/output/logstash_output_riemann_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::output::riemann', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :debug => false, 13 | :exclude_tags => ['value2'], 14 | :fields => ['value3'], 15 | :host => 'value4', 16 | :port => 5, 17 | :protocol => 'tcp', 18 | :riemann_event => { 'field7' => 'value7' }, 19 | :sender => 'value8', 20 | :tags => ['value9'], 21 | :type => 'value10', 22 | } end 23 | 24 | it { should contain_file('/etc/logstash/agent/config/output_riemann_test').with(:content => "output {\n riemann {\n debug => false\n exclude_tags => ['value2']\n fields => ['value3']\n host => \"value4\"\n port => 5\n protocol => \"tcp\"\n riemann_event => [\"field7\", \"value7\"]\n sender => \"value8\"\n tags => ['value9']\n type => \"value10\"\n }\n}\n") } 25 | end 26 | 27 | context "Instance test" do 28 | 29 | let :params do { 30 | :debug => false, 31 | :exclude_tags => ['value2'], 32 | :fields => ['value3'], 33 | :host => 'value4', 34 | :port => 5, 35 | :protocol => 'tcp', 36 | :riemann_event => { 'field7' => 'value7' }, 37 | :sender => 'value8', 38 | :tags => ['value9'], 39 | :type => 'value10', 40 | :instances => [ 'agent1', 'agent2' ] 41 | } end 42 | 43 | it { should contain_file('/etc/logstash/agent1/config/output_riemann_test') } 44 | it { should contain_file('/etc/logstash/agent2/config/output_riemann_test') } 45 | 46 | end 47 | 48 | context "Set file owner" do 49 | 50 | let(:facts) { {:operatingsystem => 'CentOS' }} 51 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 52 | let(:title) { 'test' } 53 | 54 | let :params do { 55 | :debug => false, 56 | :exclude_tags => ['value2'], 57 | :fields => ['value3'], 58 | :host => 'value4', 59 | :port => 5, 60 | :protocol => 'tcp', 61 | :riemann_event => { 'field7' => 'value7' }, 62 | :sender => 'value8', 63 | :tags => ['value9'], 64 | :type => 'value10', 65 | } end 66 | 67 | it { should contain_file('/etc/logstash/agent/config/output_riemann_test').with(:owner => 'logstash', :group => 'logstash') } 68 | 69 | end 70 | 71 | end 72 | -------------------------------------------------------------------------------- /spec/defines/input/logstash_input_snmptrap_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::input::snmptrap', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :charset => 'ASCII-8BIT', 14 | :community => 'value3', 15 | :debug => false, 16 | :format => 'plain', 17 | :host => 'value6', 18 | :message_format => 'value7', 19 | :port => 8, 20 | :tags => ['value9'], 21 | :type => 'value10', 22 | } end 23 | 24 | it { should contain_file('/etc/logstash/agent/config/input_snmptrap_test').with(:content => "input {\n snmptrap {\n add_field => [\"field1\", \"value1\"]\n charset => \"ASCII-8BIT\"\n community => \"value3\"\n debug => false\n format => \"plain\"\n host => \"value6\"\n message_format => \"value7\"\n port => 8\n tags => ['value9']\n type => \"value10\"\n }\n}\n") } 25 | end 26 | 27 | context "Instance test" do 28 | 29 | let :params do { 30 | :add_field => { 'field1' => 'value1' }, 31 | :charset => 'ASCII-8BIT', 32 | :community => 'value3', 33 | :debug => false, 34 | :format => 'plain', 35 | :host => 'value6', 36 | :message_format => 'value7', 37 | :port => 8, 38 | :tags => ['value9'], 39 | :type => 'value10', 40 | :instances => [ 'agent1', 'agent2' ] 41 | } end 42 | 43 | it { should contain_file('/etc/logstash/agent1/config/input_snmptrap_test') } 44 | it { should contain_file('/etc/logstash/agent2/config/input_snmptrap_test') } 45 | 46 | end 47 | 48 | context "Set file owner" do 49 | 50 | let(:facts) { {:operatingsystem => 'CentOS' }} 51 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 52 | let(:title) { 'test' } 53 | 54 | let :params do { 55 | :add_field => { 'field1' => 'value1' }, 56 | :charset => 'ASCII-8BIT', 57 | :community => 'value3', 58 | :debug => false, 59 | :format => 'plain', 60 | :host => 'value6', 61 | :message_format => 'value7', 62 | :port => 8, 63 | :tags => ['value9'], 64 | :type => 'value10', 65 | } end 66 | 67 | it { should contain_file('/etc/logstash/agent/config/input_snmptrap_test').with(:owner => 'logstash', :group => 'logstash') } 68 | 69 | end 70 | 71 | end 72 | -------------------------------------------------------------------------------- /spec/defines/output/logstash_output_elasticsearch_http_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::output::elasticsearch_http', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :document_id => 'value1', 13 | :exclude_tags => ['value2'], 14 | :fields => ['value3'], 15 | :flush_size => 4, 16 | :host => 'value5', 17 | :index => 'value6', 18 | :index_type => 'value7', 19 | :port => 8, 20 | :tags => ['value9'], 21 | :type => 'value10', 22 | } end 23 | 24 | it { should contain_file('/etc/logstash/agent/config/output_elasticsearch_http_test').with(:content => "output {\n elasticsearch_http {\n document_id => \"value1\"\n exclude_tags => ['value2']\n fields => ['value3']\n flush_size => 4\n host => \"value5\"\n index => \"value6\"\n index_type => \"value7\"\n port => 8\n tags => ['value9']\n type => \"value10\"\n }\n}\n") } 25 | end 26 | 27 | context "Instance test" do 28 | 29 | let :params do { 30 | :document_id => 'value1', 31 | :exclude_tags => ['value2'], 32 | :fields => ['value3'], 33 | :flush_size => 4, 34 | :host => 'value5', 35 | :index => 'value6', 36 | :index_type => 'value7', 37 | :port => 8, 38 | :tags => ['value9'], 39 | :type => 'value10', 40 | :instances => [ 'agent1', 'agent2' ] 41 | } end 42 | 43 | it { should contain_file('/etc/logstash/agent1/config/output_elasticsearch_http_test') } 44 | it { should contain_file('/etc/logstash/agent2/config/output_elasticsearch_http_test') } 45 | 46 | end 47 | 48 | context "Set file owner" do 49 | 50 | let(:facts) { {:operatingsystem => 'CentOS' }} 51 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 52 | let(:title) { 'test' } 53 | 54 | let :params do { 55 | :document_id => 'value1', 56 | :exclude_tags => ['value2'], 57 | :fields => ['value3'], 58 | :flush_size => 4, 59 | :host => 'value5', 60 | :index => 'value6', 61 | :index_type => 'value7', 62 | :port => 8, 63 | :tags => ['value9'], 64 | :type => 'value10', 65 | } end 66 | 67 | it { should contain_file('/etc/logstash/agent/config/output_elasticsearch_http_test').with(:owner => 'logstash', :group => 'logstash') } 68 | 69 | end 70 | 71 | end 72 | -------------------------------------------------------------------------------- /spec/defines/output/logstash_output_zabbix_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::output::zabbix', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :exclude_tags => ['value1'], 13 | :fields => ['value2'], 14 | :host => 'value3', 15 | :port => 4, 16 | :tags => ['value5'], 17 | :type => 'value6', 18 | :zabbix_sender => 'puppet:///path/to/file7', 19 | } end 20 | 21 | it { should contain_file('/etc/logstash/agent/config/output_zabbix_test').with(:content => "output {\n zabbix {\n exclude_tags => ['value1']\n fields => ['value2']\n host => \"value3\"\n port => 4\n tags => ['value5']\n type => \"value6\"\n zabbix_sender => \"/etc/logstash/files/output/zabbix/test/file7\"\n }\n}\n") } 22 | it { should contain_file('/etc/logstash/files/output/zabbix/test/file7').with(:source => 'puppet:///path/to/file7') } 23 | it { should contain_file('/etc/logstash/files/output/zabbix/test') } 24 | it { should contain_exec('create_files_dir_output_zabbix_test').with(:command => 'mkdir -p /etc/logstash/files/output/zabbix/test') } 25 | end 26 | 27 | context "Instance test" do 28 | 29 | let :params do { 30 | :exclude_tags => ['value1'], 31 | :fields => ['value2'], 32 | :host => 'value3', 33 | :port => 4, 34 | :tags => ['value5'], 35 | :type => 'value6', 36 | :zabbix_sender => 'puppet:///path/to/file7', 37 | :instances => [ 'agent1', 'agent2' ] 38 | } end 39 | 40 | it { should contain_file('/etc/logstash/agent1/config/output_zabbix_test') } 41 | it { should contain_file('/etc/logstash/agent2/config/output_zabbix_test') } 42 | 43 | end 44 | 45 | context "Set file owner" do 46 | 47 | let(:facts) { {:operatingsystem => 'CentOS' }} 48 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 49 | let(:title) { 'test' } 50 | 51 | let :params do { 52 | :exclude_tags => ['value1'], 53 | :fields => ['value2'], 54 | :host => 'value3', 55 | :port => 4, 56 | :tags => ['value5'], 57 | :type => 'value6', 58 | :zabbix_sender => 'puppet:///path/to/file7', 59 | } end 60 | 61 | it { should contain_file('/etc/logstash/agent/config/output_zabbix_test').with(:owner => 'logstash', :group => 'logstash') } 62 | 63 | end 64 | 65 | end 66 | -------------------------------------------------------------------------------- /spec/defines/filter/logstash_filter_alter_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::filter::alter', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :add_tag => ['value2'], 14 | :coalesce => ['value3'], 15 | :condrewrite => ['value4'], 16 | :condrewriteother => ['value5'], 17 | :exclude_tags => ['value6'], 18 | :remove_tag => ['value7'], 19 | :tags => ['value8'], 20 | :type => 'value9', 21 | } end 22 | 23 | it { should contain_file('/etc/logstash/agent/config/filter_10_alter_test').with(:content => "filter {\n alter {\n add_field => [\"field1\", \"value1\"]\n add_tag => ['value2']\n coalesce => ['value3']\n condrewrite => ['value4']\n condrewriteother => ['value5']\n exclude_tags => ['value6']\n remove_tag => ['value7']\n tags => ['value8']\n type => \"value9\"\n }\n}\n") } 24 | end 25 | 26 | context "Instance test" do 27 | 28 | let :params do { 29 | :add_field => { 'field1' => 'value1' }, 30 | :add_tag => ['value2'], 31 | :coalesce => ['value3'], 32 | :condrewrite => ['value4'], 33 | :condrewriteother => ['value5'], 34 | :exclude_tags => ['value6'], 35 | :remove_tag => ['value7'], 36 | :tags => ['value8'], 37 | :type => 'value9', 38 | :instances => [ 'agent1', 'agent2' ] 39 | } end 40 | 41 | it { should contain_file('/etc/logstash/agent1/config/filter_10_alter_test') } 42 | it { should contain_file('/etc/logstash/agent2/config/filter_10_alter_test') } 43 | 44 | end 45 | 46 | context "Set file owner" do 47 | 48 | let(:facts) { {:operatingsystem => 'CentOS' }} 49 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 50 | let(:title) { 'test' } 51 | 52 | let :params do { 53 | :add_field => { 'field1' => 'value1' }, 54 | :add_tag => ['value2'], 55 | :coalesce => ['value3'], 56 | :condrewrite => ['value4'], 57 | :condrewriteother => ['value5'], 58 | :exclude_tags => ['value6'], 59 | :remove_tag => ['value7'], 60 | :tags => ['value8'], 61 | :type => 'value9', 62 | } end 63 | 64 | it { should contain_file('/etc/logstash/agent/config/filter_10_alter_test').with(:owner => 'logstash', :group => 'logstash') } 65 | 66 | end 67 | 68 | end 69 | -------------------------------------------------------------------------------- /spec/defines/filter/logstash_filter_metrics_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::filter::metrics', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :add_tag => ['value2'], 14 | :exclude_tags => ['value3'], 15 | :ignore_older_than => 4, 16 | :meter => ['value5'], 17 | :remove_tag => ['value6'], 18 | :tags => ['value7'], 19 | :timer => { 'field8' => 'value8' }, 20 | :type => 'value9', 21 | } end 22 | 23 | it { should contain_file('/etc/logstash/agent/config/filter_10_metrics_test').with(:content => "filter {\n metrics {\n add_field => [\"field1\", \"value1\"]\n add_tag => ['value2']\n exclude_tags => ['value3']\n ignore_older_than => 4\n meter => ['value5']\n remove_tag => ['value6']\n tags => ['value7']\n timer => [\"field8\", \"value8\"]\n type => \"value9\"\n }\n}\n") } 24 | end 25 | 26 | context "Instance test" do 27 | 28 | let :params do { 29 | :add_field => { 'field1' => 'value1' }, 30 | :add_tag => ['value2'], 31 | :exclude_tags => ['value3'], 32 | :ignore_older_than => 4, 33 | :meter => ['value5'], 34 | :remove_tag => ['value6'], 35 | :tags => ['value7'], 36 | :timer => { 'field8' => 'value8' }, 37 | :type => 'value9', 38 | :instances => [ 'agent1', 'agent2' ] 39 | } end 40 | 41 | it { should contain_file('/etc/logstash/agent1/config/filter_10_metrics_test') } 42 | it { should contain_file('/etc/logstash/agent2/config/filter_10_metrics_test') } 43 | 44 | end 45 | 46 | context "Set file owner" do 47 | 48 | let(:facts) { {:operatingsystem => 'CentOS' }} 49 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 50 | let(:title) { 'test' } 51 | 52 | let :params do { 53 | :add_field => { 'field1' => 'value1' }, 54 | :add_tag => ['value2'], 55 | :exclude_tags => ['value3'], 56 | :ignore_older_than => 4, 57 | :meter => ['value5'], 58 | :remove_tag => ['value6'], 59 | :tags => ['value7'], 60 | :timer => { 'field8' => 'value8' }, 61 | :type => 'value9', 62 | } end 63 | 64 | it { should contain_file('/etc/logstash/agent/config/filter_10_metrics_test').with(:owner => 'logstash', :group => 'logstash') } 65 | 66 | end 67 | 68 | end 69 | -------------------------------------------------------------------------------- /spec/defines/output/logstash_output_juggernaut_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::output::juggernaut', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :channels => ['value1'], 13 | :db => 2, 14 | :exclude_tags => ['value3'], 15 | :fields => ['value4'], 16 | :host => 'value5', 17 | :message_format => 'value6', 18 | :password => 'value7', 19 | :port => 8, 20 | :tags => ['value9'], 21 | :timeout => 10, 22 | :type => 'value11', 23 | } end 24 | 25 | it { should contain_file('/etc/logstash/agent/config/output_juggernaut_test').with(:content => "output {\n juggernaut {\n channels => ['value1']\n db => 2\n exclude_tags => ['value3']\n fields => ['value4']\n host => \"value5\"\n message_format => \"value6\"\n password => \"value7\"\n port => 8\n tags => ['value9']\n timeout => 10\n type => \"value11\"\n }\n}\n") } 26 | end 27 | 28 | context "Instance test" do 29 | 30 | let :params do { 31 | :channels => ['value1'], 32 | :db => 2, 33 | :exclude_tags => ['value3'], 34 | :fields => ['value4'], 35 | :host => 'value5', 36 | :message_format => 'value6', 37 | :password => 'value7', 38 | :port => 8, 39 | :tags => ['value9'], 40 | :timeout => 10, 41 | :type => 'value11', 42 | :instances => [ 'agent1', 'agent2' ] 43 | } end 44 | 45 | it { should contain_file('/etc/logstash/agent1/config/output_juggernaut_test') } 46 | it { should contain_file('/etc/logstash/agent2/config/output_juggernaut_test') } 47 | 48 | end 49 | 50 | context "Set file owner" do 51 | 52 | let(:facts) { {:operatingsystem => 'CentOS' }} 53 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 54 | let(:title) { 'test' } 55 | 56 | let :params do { 57 | :channels => ['value1'], 58 | :db => 2, 59 | :exclude_tags => ['value3'], 60 | :fields => ['value4'], 61 | :host => 'value5', 62 | :message_format => 'value6', 63 | :password => 'value7', 64 | :port => 8, 65 | :tags => ['value9'], 66 | :timeout => 10, 67 | :type => 'value11', 68 | } end 69 | 70 | it { should contain_file('/etc/logstash/agent/config/output_juggernaut_test').with(:owner => 'logstash', :group => 'logstash') } 71 | 72 | end 73 | 74 | end 75 | -------------------------------------------------------------------------------- /spec/defines/output/logstash_output_sqs_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::output::sqs', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :access_key_id => 'value1', 13 | :aws_credentials_file => 'value2', 14 | :exclude_tags => ['value3'], 15 | :fields => ['value4'], 16 | :queue => 'value5', 17 | :region => 'us-east-1', 18 | :secret_access_key => 'value7', 19 | :tags => ['value8'], 20 | :type => 'value9', 21 | :use_ssl => false, 22 | } end 23 | 24 | it { should contain_file('/etc/logstash/agent/config/output_sqs_test').with(:content => "output {\n sqs {\n access_key_id => \"value1\"\n aws_credentials_file => \"value2\"\n exclude_tags => ['value3']\n fields => ['value4']\n queue => \"value5\"\n region => \"us-east-1\"\n secret_access_key => \"value7\"\n tags => ['value8']\n type => \"value9\"\n use_ssl => false\n }\n}\n") } 25 | end 26 | 27 | context "Instance test" do 28 | 29 | let :params do { 30 | :access_key_id => 'value1', 31 | :aws_credentials_file => 'value2', 32 | :exclude_tags => ['value3'], 33 | :fields => ['value4'], 34 | :queue => 'value5', 35 | :region => 'us-east-1', 36 | :secret_access_key => 'value7', 37 | :tags => ['value8'], 38 | :type => 'value9', 39 | :use_ssl => false, 40 | :instances => [ 'agent1', 'agent2' ] 41 | } end 42 | 43 | it { should contain_file('/etc/logstash/agent1/config/output_sqs_test') } 44 | it { should contain_file('/etc/logstash/agent2/config/output_sqs_test') } 45 | 46 | end 47 | 48 | context "Set file owner" do 49 | 50 | let(:facts) { {:operatingsystem => 'CentOS' }} 51 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 52 | let(:title) { 'test' } 53 | 54 | let :params do { 55 | :access_key_id => 'value1', 56 | :aws_credentials_file => 'value2', 57 | :exclude_tags => ['value3'], 58 | :fields => ['value4'], 59 | :queue => 'value5', 60 | :region => 'us-east-1', 61 | :secret_access_key => 'value7', 62 | :tags => ['value8'], 63 | :type => 'value9', 64 | :use_ssl => false, 65 | } end 66 | 67 | it { should contain_file('/etc/logstash/agent/config/output_sqs_test').with(:owner => 'logstash', :group => 'logstash') } 68 | 69 | end 70 | 71 | end 72 | -------------------------------------------------------------------------------- /spec/defines/filter/logstash_filter_csv_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::filter::csv', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :add_tag => ['value2'], 14 | :columns => ['value3'], 15 | :exclude_tags => ['value4'], 16 | :remove_tag => ['value5'], 17 | :separator => 'value6', 18 | :source => 'value7', 19 | :tags => ['value8'], 20 | :target => 'value9', 21 | :type => 'value10', 22 | } end 23 | 24 | it { should contain_file('/etc/logstash/agent/config/filter_10_csv_test').with(:content => "filter {\n csv {\n add_field => [\"field1\", \"value1\"]\n add_tag => ['value2']\n columns => ['value3']\n exclude_tags => ['value4']\n remove_tag => ['value5']\n separator => \"value6\"\n source => \"value7\"\n tags => ['value8']\n target => \"value9\"\n type => \"value10\"\n }\n}\n") } 25 | end 26 | 27 | context "Instance test" do 28 | 29 | let :params do { 30 | :add_field => { 'field1' => 'value1' }, 31 | :add_tag => ['value2'], 32 | :columns => ['value3'], 33 | :exclude_tags => ['value4'], 34 | :remove_tag => ['value5'], 35 | :separator => 'value6', 36 | :source => 'value7', 37 | :tags => ['value8'], 38 | :target => 'value9', 39 | :type => 'value10', 40 | :instances => [ 'agent1', 'agent2' ] 41 | } end 42 | 43 | it { should contain_file('/etc/logstash/agent1/config/filter_10_csv_test') } 44 | it { should contain_file('/etc/logstash/agent2/config/filter_10_csv_test') } 45 | 46 | end 47 | 48 | context "Set file owner" do 49 | 50 | let(:facts) { {:operatingsystem => 'CentOS' }} 51 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 52 | let(:title) { 'test' } 53 | 54 | let :params do { 55 | :add_field => { 'field1' => 'value1' }, 56 | :add_tag => ['value2'], 57 | :columns => ['value3'], 58 | :exclude_tags => ['value4'], 59 | :remove_tag => ['value5'], 60 | :separator => 'value6', 61 | :source => 'value7', 62 | :tags => ['value8'], 63 | :target => 'value9', 64 | :type => 'value10', 65 | } end 66 | 67 | it { should contain_file('/etc/logstash/agent/config/filter_10_csv_test').with(:owner => 'logstash', :group => 'logstash') } 68 | 69 | end 70 | 71 | end 72 | -------------------------------------------------------------------------------- /spec/defines/input/logstash_input_log4j_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::input::log4j', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :charset => 'ASCII-8BIT', 14 | :data_timeout => 3, 15 | :debug => false, 16 | :format => 'plain', 17 | :host => 'value6', 18 | :message_format => 'value7', 19 | :mode => 'server', 20 | :port => 9, 21 | :tags => ['value10'], 22 | :type => 'value11', 23 | } end 24 | 25 | it { should contain_file('/etc/logstash/agent/config/input_log4j_test').with(:content => "input {\n log4j {\n add_field => [\"field1\", \"value1\"]\n charset => \"ASCII-8BIT\"\n data_timeout => 3\n debug => false\n format => \"plain\"\n host => \"value6\"\n message_format => \"value7\"\n mode => \"server\"\n port => 9\n tags => ['value10']\n type => \"value11\"\n }\n}\n") } 26 | end 27 | 28 | context "Instance test" do 29 | 30 | let :params do { 31 | :add_field => { 'field1' => 'value1' }, 32 | :charset => 'ASCII-8BIT', 33 | :data_timeout => 3, 34 | :debug => false, 35 | :format => 'plain', 36 | :host => 'value6', 37 | :message_format => 'value7', 38 | :mode => 'server', 39 | :port => 9, 40 | :tags => ['value10'], 41 | :type => 'value11', 42 | :instances => [ 'agent1', 'agent2' ] 43 | } end 44 | 45 | it { should contain_file('/etc/logstash/agent1/config/input_log4j_test') } 46 | it { should contain_file('/etc/logstash/agent2/config/input_log4j_test') } 47 | 48 | end 49 | 50 | context "Set file owner" do 51 | 52 | let(:facts) { {:operatingsystem => 'CentOS' }} 53 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 54 | let(:title) { 'test' } 55 | 56 | let :params do { 57 | :add_field => { 'field1' => 'value1' }, 58 | :charset => 'ASCII-8BIT', 59 | :data_timeout => 3, 60 | :debug => false, 61 | :format => 'plain', 62 | :host => 'value6', 63 | :message_format => 'value7', 64 | :mode => 'server', 65 | :port => 9, 66 | :tags => ['value10'], 67 | :type => 'value11', 68 | } end 69 | 70 | it { should contain_file('/etc/logstash/agent/config/input_log4j_test').with(:owner => 'logstash', :group => 'logstash') } 71 | 72 | end 73 | 74 | end 75 | -------------------------------------------------------------------------------- /spec/defines/filter/logstash_filter_xml_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::filter::xml', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :add_tag => ['value2'], 14 | :exclude_tags => ['value3'], 15 | :remove_tag => ['value4'], 16 | :source => 'value5', 17 | :store_xml => false, 18 | :tags => ['value7'], 19 | :target => 'value8', 20 | :type => 'value9', 21 | :xpath => { 'field10' => 'value10' }, 22 | } end 23 | 24 | it { should contain_file('/etc/logstash/agent/config/filter_10_xml_test').with(:content => "filter {\n xml {\n add_field => [\"field1\", \"value1\"]\n add_tag => ['value2']\n exclude_tags => ['value3']\n remove_tag => ['value4']\n source => \"value5\"\n store_xml => false\n tags => ['value7']\n target => \"value8\"\n type => \"value9\"\n xpath => [\"field10\", \"value10\"]\n }\n}\n") } 25 | end 26 | 27 | context "Instance test" do 28 | 29 | let :params do { 30 | :add_field => { 'field1' => 'value1' }, 31 | :add_tag => ['value2'], 32 | :exclude_tags => ['value3'], 33 | :remove_tag => ['value4'], 34 | :source => 'value5', 35 | :store_xml => false, 36 | :tags => ['value7'], 37 | :target => 'value8', 38 | :type => 'value9', 39 | :xpath => { 'field10' => 'value10' }, 40 | :instances => [ 'agent1', 'agent2' ] 41 | } end 42 | 43 | it { should contain_file('/etc/logstash/agent1/config/filter_10_xml_test') } 44 | it { should contain_file('/etc/logstash/agent2/config/filter_10_xml_test') } 45 | 46 | end 47 | 48 | context "Set file owner" do 49 | 50 | let(:facts) { {:operatingsystem => 'CentOS' }} 51 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 52 | let(:title) { 'test' } 53 | 54 | let :params do { 55 | :add_field => { 'field1' => 'value1' }, 56 | :add_tag => ['value2'], 57 | :exclude_tags => ['value3'], 58 | :remove_tag => ['value4'], 59 | :source => 'value5', 60 | :store_xml => false, 61 | :tags => ['value7'], 62 | :target => 'value8', 63 | :type => 'value9', 64 | :xpath => { 'field10' => 'value10' }, 65 | } end 66 | 67 | it { should contain_file('/etc/logstash/agent/config/filter_10_xml_test').with(:owner => 'logstash', :group => 'logstash') } 68 | 69 | end 70 | 71 | end 72 | -------------------------------------------------------------------------------- /spec/defines/input/logstash_input_generator_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::input::generator', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :charset => 'ASCII-8BIT', 14 | :count => 3, 15 | :debug => false, 16 | :format => 'plain', 17 | :lines => ['value6'], 18 | :message => 'value7', 19 | :message_format => 'value8', 20 | :tags => ['value9'], 21 | :threads => 10, 22 | :type => 'value11', 23 | } end 24 | 25 | it { should contain_file('/etc/logstash/agent/config/input_generator_test').with(:content => "input {\n generator {\n add_field => [\"field1\", \"value1\"]\n charset => \"ASCII-8BIT\"\n count => 3\n debug => false\n format => \"plain\"\n lines => ['value6']\n message => \"value7\"\n message_format => \"value8\"\n tags => ['value9']\n threads => 10\n type => \"value11\"\n }\n}\n") } 26 | end 27 | 28 | context "Instance test" do 29 | 30 | let :params do { 31 | :add_field => { 'field1' => 'value1' }, 32 | :charset => 'ASCII-8BIT', 33 | :count => 3, 34 | :debug => false, 35 | :format => 'plain', 36 | :lines => ['value6'], 37 | :message => 'value7', 38 | :message_format => 'value8', 39 | :tags => ['value9'], 40 | :threads => 10, 41 | :type => 'value11', 42 | :instances => [ 'agent1', 'agent2' ] 43 | } end 44 | 45 | it { should contain_file('/etc/logstash/agent1/config/input_generator_test') } 46 | it { should contain_file('/etc/logstash/agent2/config/input_generator_test') } 47 | 48 | end 49 | 50 | context "Set file owner" do 51 | 52 | let(:facts) { {:operatingsystem => 'CentOS' }} 53 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 54 | let(:title) { 'test' } 55 | 56 | let :params do { 57 | :add_field => { 'field1' => 'value1' }, 58 | :charset => 'ASCII-8BIT', 59 | :count => 3, 60 | :debug => false, 61 | :format => 'plain', 62 | :lines => ['value6'], 63 | :message => 'value7', 64 | :message_format => 'value8', 65 | :tags => ['value9'], 66 | :threads => 10, 67 | :type => 'value11', 68 | } end 69 | 70 | it { should contain_file('/etc/logstash/agent/config/input_generator_test').with(:owner => 'logstash', :group => 'logstash') } 71 | 72 | end 73 | 74 | end 75 | -------------------------------------------------------------------------------- /spec/defines/output/logstash_output_loggly_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::output::loggly', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :exclude_tags => ['value1'], 13 | :fields => ['value2'], 14 | :host => 'value3', 15 | :key => 'value4', 16 | :proto => 'value5', 17 | :proxy_host => 'value6', 18 | :proxy_password => 'value7', 19 | :proxy_port => 8, 20 | :proxy_user => 'value9', 21 | :tags => ['value10'], 22 | :type => 'value11', 23 | } end 24 | 25 | it { should contain_file('/etc/logstash/agent/config/output_loggly_test').with(:content => "output {\n loggly {\n exclude_tags => ['value1']\n fields => ['value2']\n host => \"value3\"\n key => \"value4\"\n proto => \"value5\"\n proxy_host => \"value6\"\n proxy_password => \"value7\"\n proxy_port => 8\n proxy_user => \"value9\"\n tags => ['value10']\n type => \"value11\"\n }\n}\n") } 26 | end 27 | 28 | context "Instance test" do 29 | 30 | let :params do { 31 | :exclude_tags => ['value1'], 32 | :fields => ['value2'], 33 | :host => 'value3', 34 | :key => 'value4', 35 | :proto => 'value5', 36 | :proxy_host => 'value6', 37 | :proxy_password => 'value7', 38 | :proxy_port => 8, 39 | :proxy_user => 'value9', 40 | :tags => ['value10'], 41 | :type => 'value11', 42 | :instances => [ 'agent1', 'agent2' ] 43 | } end 44 | 45 | it { should contain_file('/etc/logstash/agent1/config/output_loggly_test') } 46 | it { should contain_file('/etc/logstash/agent2/config/output_loggly_test') } 47 | 48 | end 49 | 50 | context "Set file owner" do 51 | 52 | let(:facts) { {:operatingsystem => 'CentOS' }} 53 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 54 | let(:title) { 'test' } 55 | 56 | let :params do { 57 | :exclude_tags => ['value1'], 58 | :fields => ['value2'], 59 | :host => 'value3', 60 | :key => 'value4', 61 | :proto => 'value5', 62 | :proxy_host => 'value6', 63 | :proxy_password => 'value7', 64 | :proxy_port => 8, 65 | :proxy_user => 'value9', 66 | :tags => ['value10'], 67 | :type => 'value11', 68 | } end 69 | 70 | it { should contain_file('/etc/logstash/agent/config/output_loggly_test').with(:owner => 'logstash', :group => 'logstash') } 71 | 72 | end 73 | 74 | end 75 | -------------------------------------------------------------------------------- /spec/defines/input/logstash_input_xmpp_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::input::xmpp', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :charset => 'ASCII-8BIT', 14 | :debug => false, 15 | :format => 'plain', 16 | :host => 'value5', 17 | :message_format => 'value6', 18 | :password => 'value7', 19 | :rooms => ['value8'], 20 | :tags => ['value9'], 21 | :type => 'value10', 22 | :user => 'value11', 23 | } end 24 | 25 | it { should contain_file('/etc/logstash/agent/config/input_xmpp_test').with(:content => "input {\n xmpp {\n add_field => [\"field1\", \"value1\"]\n charset => \"ASCII-8BIT\"\n debug => false\n format => \"plain\"\n host => \"value5\"\n message_format => \"value6\"\n password => \"value7\"\n rooms => ['value8']\n tags => ['value9']\n type => \"value10\"\n user => \"value11\"\n }\n}\n") } 26 | end 27 | 28 | context "Instance test" do 29 | 30 | let :params do { 31 | :add_field => { 'field1' => 'value1' }, 32 | :charset => 'ASCII-8BIT', 33 | :debug => false, 34 | :format => 'plain', 35 | :host => 'value5', 36 | :message_format => 'value6', 37 | :password => 'value7', 38 | :rooms => ['value8'], 39 | :tags => ['value9'], 40 | :type => 'value10', 41 | :user => 'value11', 42 | :instances => [ 'agent1', 'agent2' ] 43 | } end 44 | 45 | it { should contain_file('/etc/logstash/agent1/config/input_xmpp_test') } 46 | it { should contain_file('/etc/logstash/agent2/config/input_xmpp_test') } 47 | 48 | end 49 | 50 | context "Set file owner" do 51 | 52 | let(:facts) { {:operatingsystem => 'CentOS' }} 53 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 54 | let(:title) { 'test' } 55 | 56 | let :params do { 57 | :add_field => { 'field1' => 'value1' }, 58 | :charset => 'ASCII-8BIT', 59 | :debug => false, 60 | :format => 'plain', 61 | :host => 'value5', 62 | :message_format => 'value6', 63 | :password => 'value7', 64 | :rooms => ['value8'], 65 | :tags => ['value9'], 66 | :type => 'value10', 67 | :user => 'value11', 68 | } end 69 | 70 | it { should contain_file('/etc/logstash/agent/config/input_xmpp_test').with(:owner => 'logstash', :group => 'logstash') } 71 | 72 | end 73 | 74 | end 75 | -------------------------------------------------------------------------------- /spec/defines/output/logstash_output_pagerduty_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::output::pagerduty', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :description => 'value1', 13 | :details => { 'field2' => 'value2' }, 14 | :event_type => 'trigger', 15 | :exclude_tags => ['value4'], 16 | :fields => ['value5'], 17 | :incident_key => 'value6', 18 | :pdurl => 'value7', 19 | :service_key => 'value8', 20 | :tags => ['value9'], 21 | :type => 'value10', 22 | } end 23 | 24 | it { should contain_file('/etc/logstash/agent/config/output_pagerduty_test').with(:content => "output {\n pagerduty {\n description => \"value1\"\n details => [\"field2\", \"value2\"]\n event_type => \"trigger\"\n exclude_tags => ['value4']\n fields => ['value5']\n incident_key => \"value6\"\n pdurl => \"value7\"\n service_key => \"value8\"\n tags => ['value9']\n type => \"value10\"\n }\n}\n") } 25 | end 26 | 27 | context "Instance test" do 28 | 29 | let :params do { 30 | :description => 'value1', 31 | :details => { 'field2' => 'value2' }, 32 | :event_type => 'trigger', 33 | :exclude_tags => ['value4'], 34 | :fields => ['value5'], 35 | :incident_key => 'value6', 36 | :pdurl => 'value7', 37 | :service_key => 'value8', 38 | :tags => ['value9'], 39 | :type => 'value10', 40 | :instances => [ 'agent1', 'agent2' ] 41 | } end 42 | 43 | it { should contain_file('/etc/logstash/agent1/config/output_pagerduty_test') } 44 | it { should contain_file('/etc/logstash/agent2/config/output_pagerduty_test') } 45 | 46 | end 47 | 48 | context "Set file owner" do 49 | 50 | let(:facts) { {:operatingsystem => 'CentOS' }} 51 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 52 | let(:title) { 'test' } 53 | 54 | let :params do { 55 | :description => 'value1', 56 | :details => { 'field2' => 'value2' }, 57 | :event_type => 'trigger', 58 | :exclude_tags => ['value4'], 59 | :fields => ['value5'], 60 | :incident_key => 'value6', 61 | :pdurl => 'value7', 62 | :service_key => 'value8', 63 | :tags => ['value9'], 64 | :type => 'value10', 65 | } end 66 | 67 | it { should contain_file('/etc/logstash/agent/config/output_pagerduty_test').with(:owner => 'logstash', :group => 'logstash') } 68 | 69 | end 70 | 71 | end 72 | -------------------------------------------------------------------------------- /spec/defines/filter/logstash_filter_zeromq_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::filter::zeromq', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :add_tag => ['value2'], 14 | :address => 'value3', 15 | :exclude_tags => ['value4'], 16 | :field => 'value5', 17 | :mode => 'server', 18 | :remove_tag => ['value7'], 19 | :sockopt => { 'field8' => 'value8' }, 20 | :tags => ['value9'], 21 | :type => 'value10', 22 | } end 23 | 24 | it { should contain_file('/etc/logstash/agent/config/filter_10_zeromq_test').with(:content => "filter {\n zeromq {\n add_field => [\"field1\", \"value1\"]\n add_tag => ['value2']\n address => \"value3\"\n exclude_tags => ['value4']\n field => \"value5\"\n mode => \"server\"\n remove_tag => ['value7']\n sockopt => [\"field8\", \"value8\"]\n tags => ['value9']\n type => \"value10\"\n }\n}\n") } 25 | end 26 | 27 | context "Instance test" do 28 | 29 | let :params do { 30 | :add_field => { 'field1' => 'value1' }, 31 | :add_tag => ['value2'], 32 | :address => 'value3', 33 | :exclude_tags => ['value4'], 34 | :field => 'value5', 35 | :mode => 'server', 36 | :remove_tag => ['value7'], 37 | :sockopt => { 'field8' => 'value8' }, 38 | :tags => ['value9'], 39 | :type => 'value10', 40 | :instances => [ 'agent1', 'agent2' ] 41 | } end 42 | 43 | it { should contain_file('/etc/logstash/agent1/config/filter_10_zeromq_test') } 44 | it { should contain_file('/etc/logstash/agent2/config/filter_10_zeromq_test') } 45 | 46 | end 47 | 48 | context "Set file owner" do 49 | 50 | let(:facts) { {:operatingsystem => 'CentOS' }} 51 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 52 | let(:title) { 'test' } 53 | 54 | let :params do { 55 | :add_field => { 'field1' => 'value1' }, 56 | :add_tag => ['value2'], 57 | :address => 'value3', 58 | :exclude_tags => ['value4'], 59 | :field => 'value5', 60 | :mode => 'server', 61 | :remove_tag => ['value7'], 62 | :sockopt => { 'field8' => 'value8' }, 63 | :tags => ['value9'], 64 | :type => 'value10', 65 | } end 66 | 67 | it { should contain_file('/etc/logstash/agent/config/filter_10_zeromq_test').with(:owner => 'logstash', :group => 'logstash') } 68 | 69 | end 70 | 71 | end 72 | -------------------------------------------------------------------------------- /spec/defines/input/logstash_input_elasticsearch_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::input::elasticsearch', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :charset => 'ASCII-8BIT', 14 | :debug => false, 15 | :format => 'plain', 16 | :host => 'value5', 17 | :index => 'value6', 18 | :message_format => 'value7', 19 | :port => 8, 20 | :query => 'value9', 21 | :tags => ['value10'], 22 | :type => 'value11', 23 | } end 24 | 25 | it { should contain_file('/etc/logstash/agent/config/input_elasticsearch_test').with(:content => "input {\n elasticsearch {\n add_field => [\"field1\", \"value1\"]\n charset => \"ASCII-8BIT\"\n debug => false\n format => \"plain\"\n host => \"value5\"\n index => \"value6\"\n message_format => \"value7\"\n port => 8\n query => \"value9\"\n tags => ['value10']\n type => \"value11\"\n }\n}\n") } 26 | end 27 | 28 | context "Instance test" do 29 | 30 | let :params do { 31 | :add_field => { 'field1' => 'value1' }, 32 | :charset => 'ASCII-8BIT', 33 | :debug => false, 34 | :format => 'plain', 35 | :host => 'value5', 36 | :index => 'value6', 37 | :message_format => 'value7', 38 | :port => 8, 39 | :query => 'value9', 40 | :tags => ['value10'], 41 | :type => 'value11', 42 | :instances => [ 'agent1', 'agent2' ] 43 | } end 44 | 45 | it { should contain_file('/etc/logstash/agent1/config/input_elasticsearch_test') } 46 | it { should contain_file('/etc/logstash/agent2/config/input_elasticsearch_test') } 47 | 48 | end 49 | 50 | context "Set file owner" do 51 | 52 | let(:facts) { {:operatingsystem => 'CentOS' }} 53 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 54 | let(:title) { 'test' } 55 | 56 | let :params do { 57 | :add_field => { 'field1' => 'value1' }, 58 | :charset => 'ASCII-8BIT', 59 | :debug => false, 60 | :format => 'plain', 61 | :host => 'value5', 62 | :index => 'value6', 63 | :message_format => 'value7', 64 | :port => 8, 65 | :query => 'value9', 66 | :tags => ['value10'], 67 | :type => 'value11', 68 | } end 69 | 70 | it { should contain_file('/etc/logstash/agent/config/input_elasticsearch_test').with(:owner => 'logstash', :group => 'logstash') } 71 | 72 | end 73 | 74 | end 75 | -------------------------------------------------------------------------------- /CHANGELOG: -------------------------------------------------------------------------------- 1 | 0.3.3 ( Jun 15, 2013 ) 2 | Enable puppet 3.2.x testing 3 | Fix issue that the config dir was missing in the init files 4 | Fix variable access deprecation warning ( PR #56 by Richard Peng ) 5 | 6 | 0.3.2 ( May 23, 2013 ) 7 | Fixing issue when using jar file without multi-instance feature 8 | Added rspec tests to cover this issue 9 | 10 | 0.3.1 ( May 15, 2013 ) 11 | Missed changes for enabling/disabling multi-instance feature 12 | Adding a few spec tests for the multi-instance feature 13 | 14 | 0.3.0 ( May 09, 2013 ) 15 | Update defines for Logstash 1.1.12 16 | Adding license file 17 | Deleted old init file removal to avoid issues. ( Issue #50 ) 18 | Allow file owner/group to be variable ( Issue/PR #47 ) 19 | Ensure log directory exists before starting ( PR #53 by Brian Lalor ) 20 | Provide complete containment of the class ( PR #53 by Brian Lalor ) 21 | Update rspec tests for new defines 22 | 23 | 0.2.0 ( Apr 30, 2013 ) 24 | Update defines for logstash 1.1.10 25 | New feature for plugins to automatically transfer files ( Issue #24 ) 26 | Create correct tmp dir ( Issue #35 ) 27 | Change file modes to be more secure ( Issue #36 ) 28 | Update defines for better input validation ( Issue #43 ) 29 | Adding rspec tests for plugin defines 30 | Fix tmp dir Debian init script ( PR #44 by Dan Carley ) 31 | 32 | 0.1.0 ( Mar 25, 2013 ) 33 | Don't backup the Jar file or the symlink ( Issue #25 by Garth Kidd ) 34 | First implementation of the multi-instance feature. This will break certain functionality. 35 | 36 | 0.0.6 ( Mar 07, 2013 ) 37 | Fix issue that the init file was overwritten 38 | Ensure we install java first before starting logstash if enabled 39 | 40 | 0.0.5 ( Mar 02, 2013 ) 41 | Adding spec tests 42 | Update Readme ( PR #20 by rjw1 ) 43 | New feature to install java 44 | 45 | 0.0.4 ( Feb 10, 2013 ) 46 | Rename Redhat to RedHat for init file ( PR #12 by pkubat ) 47 | Adding Amazon as Operating system ( PR #12 by pkubat ) 48 | Symlinking Jar file to generic name ( PR #12 by pkubat ) 49 | Correting symlink ( PR #14 by Jeff Wong ) 50 | 51 | 0.0.3 ( Feb 5, 2013 ) 52 | Clarify jarfile usage and validation ( PR #6 by Garth Kidd ) 53 | Add default Debian Init script when non provided and using custom source ( PR #7 by Garth Kidd ) 54 | Add RedHat as OS type ( PR #8 by Dan ) 55 | Skip init script when status = unmanaged ( PR #9 by Tavis Aitken ) 56 | Refactored the custom provider part ( With help of Garth Kidd ) 57 | 58 | 0.0.2 ( Jan 19, 2013 ) 59 | Adding a way to provide jar and init file instead of depending on a package 60 | 61 | 0.0.1 ( Jan 13, 2013 ) 62 | Initial release of the module 63 | -------------------------------------------------------------------------------- /spec/defines/output/logstash_output_ganglia_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::output::ganglia', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :exclude_tags => ['value1'], 13 | :fields => ['value2'], 14 | :host => 'value3', 15 | :lifetime => 4, 16 | :max_interval => 5, 17 | :metric => 'value6', 18 | :metric_type => 'string', 19 | :port => 8, 20 | :tags => ['value9'], 21 | :type => 'value10', 22 | :units => 'value11', 23 | :value => 'value12', 24 | } end 25 | 26 | it { should contain_file('/etc/logstash/agent/config/output_ganglia_test').with(:content => "output {\n ganglia {\n exclude_tags => ['value1']\n fields => ['value2']\n host => \"value3\"\n lifetime => 4\n max_interval => 5\n metric => \"value6\"\n metric_type => \"string\"\n port => 8\n tags => ['value9']\n type => \"value10\"\n units => \"value11\"\n value => \"value12\"\n }\n}\n") } 27 | end 28 | 29 | context "Instance test" do 30 | 31 | let :params do { 32 | :exclude_tags => ['value1'], 33 | :fields => ['value2'], 34 | :host => 'value3', 35 | :lifetime => 4, 36 | :max_interval => 5, 37 | :metric => 'value6', 38 | :metric_type => 'string', 39 | :port => 8, 40 | :tags => ['value9'], 41 | :type => 'value10', 42 | :units => 'value11', 43 | :value => 'value12', 44 | :instances => [ 'agent1', 'agent2' ] 45 | } end 46 | 47 | it { should contain_file('/etc/logstash/agent1/config/output_ganglia_test') } 48 | it { should contain_file('/etc/logstash/agent2/config/output_ganglia_test') } 49 | 50 | end 51 | 52 | context "Set file owner" do 53 | 54 | let(:facts) { {:operatingsystem => 'CentOS' }} 55 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 56 | let(:title) { 'test' } 57 | 58 | let :params do { 59 | :exclude_tags => ['value1'], 60 | :fields => ['value2'], 61 | :host => 'value3', 62 | :lifetime => 4, 63 | :max_interval => 5, 64 | :metric => 'value6', 65 | :metric_type => 'string', 66 | :port => 8, 67 | :tags => ['value9'], 68 | :type => 'value10', 69 | :units => 'value11', 70 | :value => 'value12', 71 | } end 72 | 73 | it { should contain_file('/etc/logstash/agent/config/output_ganglia_test').with(:owner => 'logstash', :group => 'logstash') } 74 | 75 | end 76 | 77 | end 78 | -------------------------------------------------------------------------------- /spec/defines/output/logstash_output_mongodb_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::output::mongodb', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :collection => 'value1', 13 | :database => 'value2', 14 | :exclude_tags => ['value3'], 15 | :fields => ['value4'], 16 | :host => 'value5', 17 | :isodate => false, 18 | :password => 'value7', 19 | :port => 8, 20 | :retry_delay => 9, 21 | :tags => ['value10'], 22 | :type => 'value11', 23 | :user => 'value12', 24 | } end 25 | 26 | it { should contain_file('/etc/logstash/agent/config/output_mongodb_test').with(:content => "output {\n mongodb {\n collection => \"value1\"\n database => \"value2\"\n exclude_tags => ['value3']\n fields => ['value4']\n host => \"value5\"\n isodate => false\n password => \"value7\"\n port => 8\n retry_delay => 9\n tags => ['value10']\n type => \"value11\"\n user => \"value12\"\n }\n}\n") } 27 | end 28 | 29 | context "Instance test" do 30 | 31 | let :params do { 32 | :collection => 'value1', 33 | :database => 'value2', 34 | :exclude_tags => ['value3'], 35 | :fields => ['value4'], 36 | :host => 'value5', 37 | :isodate => false, 38 | :password => 'value7', 39 | :port => 8, 40 | :retry_delay => 9, 41 | :tags => ['value10'], 42 | :type => 'value11', 43 | :user => 'value12', 44 | :instances => [ 'agent1', 'agent2' ] 45 | } end 46 | 47 | it { should contain_file('/etc/logstash/agent1/config/output_mongodb_test') } 48 | it { should contain_file('/etc/logstash/agent2/config/output_mongodb_test') } 49 | 50 | end 51 | 52 | context "Set file owner" do 53 | 54 | let(:facts) { {:operatingsystem => 'CentOS' }} 55 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 56 | let(:title) { 'test' } 57 | 58 | let :params do { 59 | :collection => 'value1', 60 | :database => 'value2', 61 | :exclude_tags => ['value3'], 62 | :fields => ['value4'], 63 | :host => 'value5', 64 | :isodate => false, 65 | :password => 'value7', 66 | :port => 8, 67 | :retry_delay => 9, 68 | :tags => ['value10'], 69 | :type => 'value11', 70 | :user => 'value12', 71 | } end 72 | 73 | it { should contain_file('/etc/logstash/agent/config/output_mongodb_test').with(:owner => 'logstash', :group => 'logstash') } 74 | 75 | end 76 | 77 | end 78 | -------------------------------------------------------------------------------- /spec/defines/output/logstash_output_lumberjack_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::output::lumberjack', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :exclude_tags => ['value1'], 13 | :fields => ['value2'], 14 | :hosts => ['value3'], 15 | :port => 4, 16 | :ssl_certificate => 'puppet:///path/to/file5', 17 | :tags => ['value6'], 18 | :type => 'value7', 19 | :window_size => 8, 20 | } end 21 | 22 | it { should contain_file('/etc/logstash/agent/config/output_lumberjack_test').with(:content => "output {\n lumberjack {\n exclude_tags => ['value1']\n fields => ['value2']\n hosts => ['value3']\n port => 4\n ssl_certificate => \"/etc/logstash/files/output/lumberjack/test/file5\"\n tags => ['value6']\n type => \"value7\"\n window_size => 8\n }\n}\n") } 23 | it { should contain_file('/etc/logstash/files/output/lumberjack/test/file5').with(:source => 'puppet:///path/to/file5') } 24 | it { should contain_file('/etc/logstash/files/output/lumberjack/test') } 25 | it { should contain_exec('create_files_dir_output_lumberjack_test').with(:command => 'mkdir -p /etc/logstash/files/output/lumberjack/test') } 26 | end 27 | 28 | context "Instance test" do 29 | 30 | let :params do { 31 | :exclude_tags => ['value1'], 32 | :fields => ['value2'], 33 | :hosts => ['value3'], 34 | :port => 4, 35 | :ssl_certificate => 'puppet:///path/to/file5', 36 | :tags => ['value6'], 37 | :type => 'value7', 38 | :window_size => 8, 39 | :instances => [ 'agent1', 'agent2' ] 40 | } end 41 | 42 | it { should contain_file('/etc/logstash/agent1/config/output_lumberjack_test') } 43 | it { should contain_file('/etc/logstash/agent2/config/output_lumberjack_test') } 44 | 45 | end 46 | 47 | context "Set file owner" do 48 | 49 | let(:facts) { {:operatingsystem => 'CentOS' }} 50 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 51 | let(:title) { 'test' } 52 | 53 | let :params do { 54 | :exclude_tags => ['value1'], 55 | :fields => ['value2'], 56 | :hosts => ['value3'], 57 | :port => 4, 58 | :ssl_certificate => 'puppet:///path/to/file5', 59 | :tags => ['value6'], 60 | :type => 'value7', 61 | :window_size => 8, 62 | } end 63 | 64 | it { should contain_file('/etc/logstash/agent/config/output_lumberjack_test').with(:owner => 'logstash', :group => 'logstash') } 65 | 66 | end 67 | 68 | end 69 | -------------------------------------------------------------------------------- /spec/defines/output/logstash_output_librato_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::output::librato', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :account_id => 'value1', 13 | :annotation => { 'field2' => 'value2' }, 14 | :api_token => 'value3', 15 | :batch_size => 'value4', 16 | :counter => { 'field5' => 'value5' }, 17 | :exclude_tags => ['value6'], 18 | :fields => ['value7'], 19 | :gauge => { 'field8' => 'value8' }, 20 | :tags => ['value9'], 21 | :type => 'value10', 22 | } end 23 | 24 | it { should contain_file('/etc/logstash/agent/config/output_librato_test').with(:content => "output {\n librato {\n account_id => \"value1\"\n annotation => [\"field2\", \"value2\"]\n api_token => \"value3\"\n batch_size => \"value4\"\n counter => [\"field5\", \"value5\"]\n exclude_tags => ['value6']\n fields => ['value7']\n gauge => [\"field8\", \"value8\"]\n tags => ['value9']\n type => \"value10\"\n }\n}\n") } 25 | end 26 | 27 | context "Instance test" do 28 | 29 | let :params do { 30 | :account_id => 'value1', 31 | :annotation => { 'field2' => 'value2' }, 32 | :api_token => 'value3', 33 | :batch_size => 'value4', 34 | :counter => { 'field5' => 'value5' }, 35 | :exclude_tags => ['value6'], 36 | :fields => ['value7'], 37 | :gauge => { 'field8' => 'value8' }, 38 | :tags => ['value9'], 39 | :type => 'value10', 40 | :instances => [ 'agent1', 'agent2' ] 41 | } end 42 | 43 | it { should contain_file('/etc/logstash/agent1/config/output_librato_test') } 44 | it { should contain_file('/etc/logstash/agent2/config/output_librato_test') } 45 | 46 | end 47 | 48 | context "Set file owner" do 49 | 50 | let(:facts) { {:operatingsystem => 'CentOS' }} 51 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 52 | let(:title) { 'test' } 53 | 54 | let :params do { 55 | :account_id => 'value1', 56 | :annotation => { 'field2' => 'value2' }, 57 | :api_token => 'value3', 58 | :batch_size => 'value4', 59 | :counter => { 'field5' => 'value5' }, 60 | :exclude_tags => ['value6'], 61 | :fields => ['value7'], 62 | :gauge => { 'field8' => 'value8' }, 63 | :tags => ['value9'], 64 | :type => 'value10', 65 | } end 66 | 67 | it { should contain_file('/etc/logstash/agent/config/output_librato_test').with(:owner => 'logstash', :group => 'logstash') } 68 | 69 | end 70 | 71 | end 72 | -------------------------------------------------------------------------------- /manifests/params.pp: -------------------------------------------------------------------------------- 1 | # == Class: logstash::params 2 | # 3 | # This class exists to 4 | # 1. Declutter the default value assignment for class parameters. 5 | # 2. Manage internally used module variables in a central place. 6 | # 7 | # Therefore, many operating system dependent differences (names, paths, ...) 8 | # are addressed in here. 9 | # 10 | # 11 | # === Parameters 12 | # 13 | # This class does not provide any parameters. 14 | # 15 | # 16 | # === Examples 17 | # 18 | # This class is not intended to be used directly. 19 | # 20 | # 21 | # === Links 22 | # 23 | # * {Puppet Docs: Using Parameterized Classes}[http://j.mp/nVpyWY] 24 | # 25 | # 26 | # === Authors 27 | # 28 | # * Richard Pijnenburg 29 | # 30 | class logstash::params { 31 | 32 | #### Default values for the parameters of the main module class, init.pp 33 | 34 | 35 | # ensure 36 | $ensure = 'present' 37 | 38 | # autoupgrade 39 | $autoupgrade = false 40 | 41 | # service status 42 | $status = 'enabled' 43 | 44 | 45 | #### Defaults for other files 46 | 47 | # Config directory 48 | $configdir = '/etc/logstash' 49 | 50 | # Logging dir 51 | $logdir = '/var/log/logstash/' 52 | 53 | # File user/group 54 | $logstash_user = 'root' 55 | $logstash_group = 'root' 56 | 57 | #### Internal module values 58 | 59 | # packages 60 | case $::operatingsystem { 61 | 'RedHat', 'CentOS', 'Fedora', 'Scientific', 'Amazon': { 62 | # main application 63 | $package = [ 'logstash' ] 64 | $installpath = '/usr/share/logstash' 65 | } 66 | 'Debian', 'Ubuntu': { 67 | # main application 68 | $package = [ 'logstash' ] 69 | $installpath = '/var/lib/logstash' 70 | } 71 | default: { 72 | fail("\"${module_name}\" provides no package default value 73 | for \"${::operatingsystem}\"") 74 | } 75 | } 76 | 77 | # service parameters 78 | case $::operatingsystem { 79 | 'RedHat', 'CentOS', 'Fedora', 'Scientific', 'Amazon': { 80 | $service_name = 'logstash' 81 | $service_hasrestart = true 82 | $service_hasstatus = true 83 | $service_pattern = $service_name 84 | $defaults_location = '/etc/sysconfig' 85 | } 86 | 'Debian', 'Ubuntu': { 87 | $service_name = 'logstash' 88 | $service_hasrestart = true 89 | $service_hasstatus = true 90 | $service_pattern = $service_name 91 | $defaults_location = '/etc/default' 92 | } 93 | default: { 94 | fail("\"${module_name}\" provides no service parameters 95 | for \"${::operatingsystem}\"") 96 | } 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /spec/defines/input/logstash_input_drupal_dblog_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::input::drupal_dblog', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :add_usernames => false, 14 | :bulksize => 3, 15 | :charset => 'ASCII-8BIT', 16 | :databases => { 'field5' => 'value5' }, 17 | :debug => false, 18 | :format => 'plain', 19 | :interval => 8, 20 | :message_format => 'value9', 21 | :tags => ['value10'], 22 | :type => 'value11', 23 | } end 24 | 25 | it { should contain_file('/etc/logstash/agent/config/input_drupal_dblog_test').with(:content => "input {\n drupal_dblog {\n add_field => [\"field1\", \"value1\"]\n add_usernames => false\n bulksize => 3\n charset => \"ASCII-8BIT\"\n databases => [\"field5\", \"value5\"]\n debug => false\n format => \"plain\"\n interval => 8\n message_format => \"value9\"\n tags => ['value10']\n type => \"value11\"\n }\n}\n") } 26 | end 27 | 28 | context "Instance test" do 29 | 30 | let :params do { 31 | :add_field => { 'field1' => 'value1' }, 32 | :add_usernames => false, 33 | :bulksize => 3, 34 | :charset => 'ASCII-8BIT', 35 | :databases => { 'field5' => 'value5' }, 36 | :debug => false, 37 | :format => 'plain', 38 | :interval => 8, 39 | :message_format => 'value9', 40 | :tags => ['value10'], 41 | :type => 'value11', 42 | :instances => [ 'agent1', 'agent2' ] 43 | } end 44 | 45 | it { should contain_file('/etc/logstash/agent1/config/input_drupal_dblog_test') } 46 | it { should contain_file('/etc/logstash/agent2/config/input_drupal_dblog_test') } 47 | 48 | end 49 | 50 | context "Set file owner" do 51 | 52 | let(:facts) { {:operatingsystem => 'CentOS' }} 53 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 54 | let(:title) { 'test' } 55 | 56 | let :params do { 57 | :add_field => { 'field1' => 'value1' }, 58 | :add_usernames => false, 59 | :bulksize => 3, 60 | :charset => 'ASCII-8BIT', 61 | :databases => { 'field5' => 'value5' }, 62 | :debug => false, 63 | :format => 'plain', 64 | :interval => 8, 65 | :message_format => 'value9', 66 | :tags => ['value10'], 67 | :type => 'value11', 68 | } end 69 | 70 | it { should contain_file('/etc/logstash/agent/config/input_drupal_dblog_test').with(:owner => 'logstash', :group => 'logstash') } 71 | 72 | end 73 | 74 | end 75 | -------------------------------------------------------------------------------- /spec/defines/input/logstash_input_stomp_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::input::stomp', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :charset => 'ASCII-8BIT', 14 | :debug => false, 15 | :destination => 'value4', 16 | :format => 'plain', 17 | :host => 'value6', 18 | :message_format => 'value7', 19 | :password => 'value8', 20 | :port => 9, 21 | :tags => ['value10'], 22 | :type => 'value11', 23 | :user => 'value12', 24 | } end 25 | 26 | it { should contain_file('/etc/logstash/agent/config/input_stomp_test').with(:content => "input {\n stomp {\n add_field => [\"field1\", \"value1\"]\n charset => \"ASCII-8BIT\"\n debug => false\n destination => \"value4\"\n format => \"plain\"\n host => \"value6\"\n message_format => \"value7\"\n password => \"value8\"\n port => 9\n tags => ['value10']\n type => \"value11\"\n user => \"value12\"\n }\n}\n") } 27 | end 28 | 29 | context "Instance test" do 30 | 31 | let :params do { 32 | :add_field => { 'field1' => 'value1' }, 33 | :charset => 'ASCII-8BIT', 34 | :debug => false, 35 | :destination => 'value4', 36 | :format => 'plain', 37 | :host => 'value6', 38 | :message_format => 'value7', 39 | :password => 'value8', 40 | :port => 9, 41 | :tags => ['value10'], 42 | :type => 'value11', 43 | :user => 'value12', 44 | :instances => [ 'agent1', 'agent2' ] 45 | } end 46 | 47 | it { should contain_file('/etc/logstash/agent1/config/input_stomp_test') } 48 | it { should contain_file('/etc/logstash/agent2/config/input_stomp_test') } 49 | 50 | end 51 | 52 | context "Set file owner" do 53 | 54 | let(:facts) { {:operatingsystem => 'CentOS' }} 55 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 56 | let(:title) { 'test' } 57 | 58 | let :params do { 59 | :add_field => { 'field1' => 'value1' }, 60 | :charset => 'ASCII-8BIT', 61 | :debug => false, 62 | :destination => 'value4', 63 | :format => 'plain', 64 | :host => 'value6', 65 | :message_format => 'value7', 66 | :password => 'value8', 67 | :port => 9, 68 | :tags => ['value10'], 69 | :type => 'value11', 70 | :user => 'value12', 71 | } end 72 | 73 | it { should contain_file('/etc/logstash/agent/config/input_stomp_test').with(:owner => 'logstash', :group => 'logstash') } 74 | 75 | end 76 | 77 | end 78 | -------------------------------------------------------------------------------- /spec/defines/output/logstash_output_boundary_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::output::boundary', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :api_key => 'value1', 13 | :auto => false, 14 | :bsubtype => 'value3', 15 | :btags => ['value4'], 16 | :btype => 'value5', 17 | :end_time => 'value6', 18 | :exclude_tags => ['value7'], 19 | :fields => ['value8'], 20 | :org_id => 'value9', 21 | :start_time => 'value10', 22 | :tags => ['value11'], 23 | :type => 'value12', 24 | } end 25 | 26 | it { should contain_file('/etc/logstash/agent/config/output_boundary_test').with(:content => "output {\n boundary {\n api_key => \"value1\"\n auto => false\n bsubtype => \"value3\"\n btags => ['value4']\n btype => \"value5\"\n end_time => \"value6\"\n exclude_tags => ['value7']\n fields => ['value8']\n org_id => \"value9\"\n start_time => \"value10\"\n tags => ['value11']\n type => \"value12\"\n }\n}\n") } 27 | end 28 | 29 | context "Instance test" do 30 | 31 | let :params do { 32 | :api_key => 'value1', 33 | :auto => false, 34 | :bsubtype => 'value3', 35 | :btags => ['value4'], 36 | :btype => 'value5', 37 | :end_time => 'value6', 38 | :exclude_tags => ['value7'], 39 | :fields => ['value8'], 40 | :org_id => 'value9', 41 | :start_time => 'value10', 42 | :tags => ['value11'], 43 | :type => 'value12', 44 | :instances => [ 'agent1', 'agent2' ] 45 | } end 46 | 47 | it { should contain_file('/etc/logstash/agent1/config/output_boundary_test') } 48 | it { should contain_file('/etc/logstash/agent2/config/output_boundary_test') } 49 | 50 | end 51 | 52 | context "Set file owner" do 53 | 54 | let(:facts) { {:operatingsystem => 'CentOS' }} 55 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 56 | let(:title) { 'test' } 57 | 58 | let :params do { 59 | :api_key => 'value1', 60 | :auto => false, 61 | :bsubtype => 'value3', 62 | :btags => ['value4'], 63 | :btype => 'value5', 64 | :end_time => 'value6', 65 | :exclude_tags => ['value7'], 66 | :fields => ['value8'], 67 | :org_id => 'value9', 68 | :start_time => 'value10', 69 | :tags => ['value11'], 70 | :type => 'value12', 71 | } end 72 | 73 | it { should contain_file('/etc/logstash/agent/config/output_boundary_test').with(:owner => 'logstash', :group => 'logstash') } 74 | 75 | end 76 | 77 | end 78 | -------------------------------------------------------------------------------- /spec/defines/filter/logstash_filter_syslog_pri_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::filter::syslog_pri', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :add_tag => ['value2'], 14 | :exclude_tags => ['value3'], 15 | :facility_labels => ['value4'], 16 | :remove_tag => ['value5'], 17 | :severity_labels => ['value6'], 18 | :syslog_pri_field_name => 'value7', 19 | :tags => ['value8'], 20 | :type => 'value9', 21 | :use_labels => false, 22 | } end 23 | 24 | it { should contain_file('/etc/logstash/agent/config/filter_10_syslog_pri_test').with(:content => "filter {\n syslog_pri {\n add_field => [\"field1\", \"value1\"]\n add_tag => ['value2']\n exclude_tags => ['value3']\n facility_labels => ['value4']\n remove_tag => ['value5']\n severity_labels => ['value6']\n syslog_pri_field_name => \"value7\"\n tags => ['value8']\n type => \"value9\"\n use_labels => false\n }\n}\n") } 25 | end 26 | 27 | context "Instance test" do 28 | 29 | let :params do { 30 | :add_field => { 'field1' => 'value1' }, 31 | :add_tag => ['value2'], 32 | :exclude_tags => ['value3'], 33 | :facility_labels => ['value4'], 34 | :remove_tag => ['value5'], 35 | :severity_labels => ['value6'], 36 | :syslog_pri_field_name => 'value7', 37 | :tags => ['value8'], 38 | :type => 'value9', 39 | :use_labels => false, 40 | :instances => [ 'agent1', 'agent2' ] 41 | } end 42 | 43 | it { should contain_file('/etc/logstash/agent1/config/filter_10_syslog_pri_test') } 44 | it { should contain_file('/etc/logstash/agent2/config/filter_10_syslog_pri_test') } 45 | 46 | end 47 | 48 | context "Set file owner" do 49 | 50 | let(:facts) { {:operatingsystem => 'CentOS' }} 51 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 52 | let(:title) { 'test' } 53 | 54 | let :params do { 55 | :add_field => { 'field1' => 'value1' }, 56 | :add_tag => ['value2'], 57 | :exclude_tags => ['value3'], 58 | :facility_labels => ['value4'], 59 | :remove_tag => ['value5'], 60 | :severity_labels => ['value6'], 61 | :syslog_pri_field_name => 'value7', 62 | :tags => ['value8'], 63 | :type => 'value9', 64 | :use_labels => false, 65 | } end 66 | 67 | it { should contain_file('/etc/logstash/agent/config/filter_10_syslog_pri_test').with(:owner => 'logstash', :group => 'logstash') } 68 | 69 | end 70 | 71 | end 72 | -------------------------------------------------------------------------------- /spec/defines/output/logstash_output_irc_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::output::irc', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :channels => ['value1'], 13 | :exclude_tags => ['value2'], 14 | :fields => ['value3'], 15 | :format => 'value4', 16 | :host => 'value5', 17 | :nick => 'value6', 18 | :password => 'value7', 19 | :port => 8, 20 | :real => 'value9', 21 | :secure => false, 22 | :tags => ['value11'], 23 | :type => 'value12', 24 | :user => 'value13', 25 | } end 26 | 27 | it { should contain_file('/etc/logstash/agent/config/output_irc_test').with(:content => "output {\n irc {\n channels => ['value1']\n exclude_tags => ['value2']\n fields => ['value3']\n format => \"value4\"\n host => \"value5\"\n nick => \"value6\"\n password => \"value7\"\n port => 8\n real => \"value9\"\n secure => false\n tags => ['value11']\n type => \"value12\"\n user => \"value13\"\n }\n}\n") } 28 | end 29 | 30 | context "Instance test" do 31 | 32 | let :params do { 33 | :channels => ['value1'], 34 | :exclude_tags => ['value2'], 35 | :fields => ['value3'], 36 | :format => 'value4', 37 | :host => 'value5', 38 | :nick => 'value6', 39 | :password => 'value7', 40 | :port => 8, 41 | :real => 'value9', 42 | :secure => false, 43 | :tags => ['value11'], 44 | :type => 'value12', 45 | :user => 'value13', 46 | :instances => [ 'agent1', 'agent2' ] 47 | } end 48 | 49 | it { should contain_file('/etc/logstash/agent1/config/output_irc_test') } 50 | it { should contain_file('/etc/logstash/agent2/config/output_irc_test') } 51 | 52 | end 53 | 54 | context "Set file owner" do 55 | 56 | let(:facts) { {:operatingsystem => 'CentOS' }} 57 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 58 | let(:title) { 'test' } 59 | 60 | let :params do { 61 | :channels => ['value1'], 62 | :exclude_tags => ['value2'], 63 | :fields => ['value3'], 64 | :format => 'value4', 65 | :host => 'value5', 66 | :nick => 'value6', 67 | :password => 'value7', 68 | :port => 8, 69 | :real => 'value9', 70 | :secure => false, 71 | :tags => ['value11'], 72 | :type => 'value12', 73 | :user => 'value13', 74 | } end 75 | 76 | it { should contain_file('/etc/logstash/agent/config/output_irc_test').with(:owner => 'logstash', :group => 'logstash') } 77 | 78 | end 79 | 80 | end 81 | -------------------------------------------------------------------------------- /spec/defines/output/logstash_output_graphtastic_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::output::graphtastic', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :batch_number => 1, 13 | :context => 'value2', 14 | :error_file => 'value3', 15 | :exclude_tags => ['value4'], 16 | :fields => ['value5'], 17 | :host => 'value6', 18 | :integration => 'udp', 19 | :metrics => { 'field8' => 'value8' }, 20 | :port => 9, 21 | :retries => 10, 22 | :tags => ['value11'], 23 | :type => 'value12', 24 | } end 25 | 26 | it { should contain_file('/etc/logstash/agent/config/output_graphtastic_test').with(:content => "output {\n graphtastic {\n batch_number => 1\n context => \"value2\"\n error_file => \"value3\"\n exclude_tags => ['value4']\n fields => ['value5']\n host => \"value6\"\n integration => \"udp\"\n metrics => [\"field8\", \"value8\"]\n port => 9\n retries => 10\n tags => ['value11']\n type => \"value12\"\n }\n}\n") } 27 | end 28 | 29 | context "Instance test" do 30 | 31 | let :params do { 32 | :batch_number => 1, 33 | :context => 'value2', 34 | :error_file => 'value3', 35 | :exclude_tags => ['value4'], 36 | :fields => ['value5'], 37 | :host => 'value6', 38 | :integration => 'udp', 39 | :metrics => { 'field8' => 'value8' }, 40 | :port => 9, 41 | :retries => 10, 42 | :tags => ['value11'], 43 | :type => 'value12', 44 | :instances => [ 'agent1', 'agent2' ] 45 | } end 46 | 47 | it { should contain_file('/etc/logstash/agent1/config/output_graphtastic_test') } 48 | it { should contain_file('/etc/logstash/agent2/config/output_graphtastic_test') } 49 | 50 | end 51 | 52 | context "Set file owner" do 53 | 54 | let(:facts) { {:operatingsystem => 'CentOS' }} 55 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 56 | let(:title) { 'test' } 57 | 58 | let :params do { 59 | :batch_number => 1, 60 | :context => 'value2', 61 | :error_file => 'value3', 62 | :exclude_tags => ['value4'], 63 | :fields => ['value5'], 64 | :host => 'value6', 65 | :integration => 'udp', 66 | :metrics => { 'field8' => 'value8' }, 67 | :port => 9, 68 | :retries => 10, 69 | :tags => ['value11'], 70 | :type => 'value12', 71 | } end 72 | 73 | it { should contain_file('/etc/logstash/agent/config/output_graphtastic_test').with(:owner => 'logstash', :group => 'logstash') } 74 | 75 | end 76 | 77 | end 78 | -------------------------------------------------------------------------------- /spec/defines/filter/logstash_filter_multiline_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::filter::multiline', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :add_tag => ['value2'], 14 | :exclude_tags => ['value3'], 15 | :negate => false, 16 | :pattern => 'value5', 17 | :patterns_dir => ['value6'], 18 | :remove_tag => ['value7'], 19 | :stream_identity => 'value8', 20 | :tags => ['value9'], 21 | :type => 'value10', 22 | :what => 'previous', 23 | } end 24 | 25 | it { should contain_file('/etc/logstash/agent/config/filter_10_multiline_test').with(:content => "filter {\n multiline {\n add_field => [\"field1\", \"value1\"]\n add_tag => ['value2']\n exclude_tags => ['value3']\n negate => false\n pattern => \"value5\"\n patterns_dir => ['value6']\n remove_tag => ['value7']\n stream_identity => \"value8\"\n tags => ['value9']\n type => \"value10\"\n what => \"previous\"\n }\n}\n") } 26 | end 27 | 28 | context "Instance test" do 29 | 30 | let :params do { 31 | :add_field => { 'field1' => 'value1' }, 32 | :add_tag => ['value2'], 33 | :exclude_tags => ['value3'], 34 | :negate => false, 35 | :pattern => 'value5', 36 | :patterns_dir => ['value6'], 37 | :remove_tag => ['value7'], 38 | :stream_identity => 'value8', 39 | :tags => ['value9'], 40 | :type => 'value10', 41 | :what => 'previous', 42 | :instances => [ 'agent1', 'agent2' ] 43 | } end 44 | 45 | it { should contain_file('/etc/logstash/agent1/config/filter_10_multiline_test') } 46 | it { should contain_file('/etc/logstash/agent2/config/filter_10_multiline_test') } 47 | 48 | end 49 | 50 | context "Set file owner" do 51 | 52 | let(:facts) { {:operatingsystem => 'CentOS' }} 53 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 54 | let(:title) { 'test' } 55 | 56 | let :params do { 57 | :add_field => { 'field1' => 'value1' }, 58 | :add_tag => ['value2'], 59 | :exclude_tags => ['value3'], 60 | :negate => false, 61 | :pattern => 'value5', 62 | :patterns_dir => ['value6'], 63 | :remove_tag => ['value7'], 64 | :stream_identity => 'value8', 65 | :tags => ['value9'], 66 | :type => 'value10', 67 | :what => 'previous', 68 | } end 69 | 70 | it { should contain_file('/etc/logstash/agent/config/filter_10_multiline_test').with(:owner => 'logstash', :group => 'logstash') } 71 | 72 | end 73 | 74 | end 75 | -------------------------------------------------------------------------------- /spec/defines/output/logstash_output_datadog_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::output::datadog', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :alert_type => 'info', 13 | :api_key => 'value2', 14 | :date_happened => 'value3', 15 | :dd_tags => ['value4'], 16 | :exclude_tags => ['value5'], 17 | :fields => ['value6'], 18 | :priority => 'normal', 19 | :source_type_name => 'nagios', 20 | :tags => ['value9'], 21 | :text => 'value10', 22 | :title => 'value11', 23 | :type => 'value12', 24 | } end 25 | 26 | it { should contain_file('/etc/logstash/agent/config/output_datadog_test').with(:content => "output {\n datadog {\n alert_type => \"info\"\n api_key => \"value2\"\n date_happened => \"value3\"\n dd_tags => ['value4']\n exclude_tags => ['value5']\n fields => ['value6']\n priority => \"normal\"\n source_type_name => \"nagios\"\n tags => ['value9']\n text => \"value10\"\n title => \"value11\"\n type => \"value12\"\n }\n}\n") } 27 | end 28 | 29 | context "Instance test" do 30 | 31 | let :params do { 32 | :alert_type => 'info', 33 | :api_key => 'value2', 34 | :date_happened => 'value3', 35 | :dd_tags => ['value4'], 36 | :exclude_tags => ['value5'], 37 | :fields => ['value6'], 38 | :priority => 'normal', 39 | :source_type_name => 'nagios', 40 | :tags => ['value9'], 41 | :text => 'value10', 42 | :title => 'value11', 43 | :type => 'value12', 44 | :instances => [ 'agent1', 'agent2' ] 45 | } end 46 | 47 | it { should contain_file('/etc/logstash/agent1/config/output_datadog_test') } 48 | it { should contain_file('/etc/logstash/agent2/config/output_datadog_test') } 49 | 50 | end 51 | 52 | context "Set file owner" do 53 | 54 | let(:facts) { {:operatingsystem => 'CentOS' }} 55 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 56 | let(:title) { 'test' } 57 | 58 | let :params do { 59 | :alert_type => 'info', 60 | :api_key => 'value2', 61 | :date_happened => 'value3', 62 | :dd_tags => ['value4'], 63 | :exclude_tags => ['value5'], 64 | :fields => ['value6'], 65 | :priority => 'normal', 66 | :source_type_name => 'nagios', 67 | :tags => ['value9'], 68 | :text => 'value10', 69 | :title => 'value11', 70 | :type => 'value12', 71 | } end 72 | 73 | it { should contain_file('/etc/logstash/agent/config/output_datadog_test').with(:owner => 'logstash', :group => 'logstash') } 74 | 75 | end 76 | 77 | end 78 | -------------------------------------------------------------------------------- /spec/defines/input/logstash_input_syslog_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::input::syslog', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :charset => 'ASCII-8BIT', 14 | :debug => false, 15 | :facility_labels => ['value4'], 16 | :format => 'plain', 17 | :host => 'value6', 18 | :message_format => 'value7', 19 | :port => 8, 20 | :severity_labels => ['value9'], 21 | :tags => ['value10'], 22 | :type => 'value11', 23 | :use_labels => false, 24 | } end 25 | 26 | it { should contain_file('/etc/logstash/agent/config/input_syslog_test').with(:content => "input {\n syslog {\n add_field => [\"field1\", \"value1\"]\n charset => \"ASCII-8BIT\"\n debug => false\n facility_labels => ['value4']\n format => \"plain\"\n host => \"value6\"\n message_format => \"value7\"\n port => 8\n severity_labels => ['value9']\n tags => ['value10']\n type => \"value11\"\n use_labels => false\n }\n}\n") } 27 | end 28 | 29 | context "Instance test" do 30 | 31 | let :params do { 32 | :add_field => { 'field1' => 'value1' }, 33 | :charset => 'ASCII-8BIT', 34 | :debug => false, 35 | :facility_labels => ['value4'], 36 | :format => 'plain', 37 | :host => 'value6', 38 | :message_format => 'value7', 39 | :port => 8, 40 | :severity_labels => ['value9'], 41 | :tags => ['value10'], 42 | :type => 'value11', 43 | :use_labels => false, 44 | :instances => [ 'agent1', 'agent2' ] 45 | } end 46 | 47 | it { should contain_file('/etc/logstash/agent1/config/input_syslog_test') } 48 | it { should contain_file('/etc/logstash/agent2/config/input_syslog_test') } 49 | 50 | end 51 | 52 | context "Set file owner" do 53 | 54 | let(:facts) { {:operatingsystem => 'CentOS' }} 55 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 56 | let(:title) { 'test' } 57 | 58 | let :params do { 59 | :add_field => { 'field1' => 'value1' }, 60 | :charset => 'ASCII-8BIT', 61 | :debug => false, 62 | :facility_labels => ['value4'], 63 | :format => 'plain', 64 | :host => 'value6', 65 | :message_format => 'value7', 66 | :port => 8, 67 | :severity_labels => ['value9'], 68 | :tags => ['value10'], 69 | :type => 'value11', 70 | :use_labels => false, 71 | } end 72 | 73 | it { should contain_file('/etc/logstash/agent/config/input_syslog_test').with(:owner => 'logstash', :group => 'logstash') } 74 | 75 | end 76 | 77 | end 78 | -------------------------------------------------------------------------------- /manifests/configdir.pp: -------------------------------------------------------------------------------- 1 | # == Define: logstash::confdir 2 | # 3 | # 4 | # 5 | # === Parameters 6 | # 7 | # 8 | # 9 | # === Examples 10 | # 11 | # 12 | # 13 | # === Authors 14 | # 15 | # * Richard Pijnenburg 16 | # 17 | define logstash::configdir { 18 | 19 | require logstash::params 20 | 21 | $config_dir = "${logstash::configdir}/${name}/config" 22 | $sincedb_dir = "${logstash::configdir}/${name}/sincedb" 23 | $pattern_dir = "${logstash::configdir}/${name}/pattern" 24 | 25 | if $logstash::ensure == 'present' { 26 | 27 | File { 28 | owner => $logstash::logstash_user, 29 | group => $logstash::logstash_group 30 | } 31 | 32 | #### Create the config dir directory 33 | exec { "create_config_dir_${name}": 34 | cwd => '/', 35 | path => ['/usr/bin', '/bin'], 36 | command => "mkdir -p ${config_dir}", 37 | creates => $config_dir; 38 | } 39 | 40 | #### Manage the config directory 41 | file { $config_dir: 42 | ensure => directory, 43 | mode => '0440', 44 | purge => true, 45 | recurse => true, 46 | require => Exec["create_config_dir_${name}"], 47 | notify => Service["logstash-${name}"]; 48 | } 49 | 50 | #### Create the sincedb directory 51 | exec { "create_sincedb_dir_${name}": 52 | cwd => '/', 53 | path => ['/usr/bin', '/bin'], 54 | command => "mkdir -p ${sincedb_dir}", 55 | creates => $sincedb_dir; 56 | } 57 | 58 | file { $sincedb_dir: 59 | ensure => directory, 60 | mode => '0640', 61 | require => Exec["create_sincedb_dir_${name}"]; 62 | } 63 | 64 | #### Create the pattern directory 65 | exec { "create_pattern_dir_${name}": 66 | cwd => '/', 67 | path => ['/usr/bin', '/bin'], 68 | command => "mkdir -p ${pattern_dir}", 69 | creates => $pattern_dir; 70 | } 71 | 72 | file { $pattern_dir: 73 | ensure => directory, 74 | mode => '0640', 75 | require => Exec["create_pattern_dir_${name}"]; 76 | } 77 | 78 | if is_hash($logstash::conffile) and has_key($logstash::conffile, $name ) { 79 | file { "${config_dir}/logstash.config": 80 | ensure => file, 81 | mode => '0440', 82 | source => $logstash::conffile[$name], 83 | } 84 | } 85 | 86 | } else { 87 | #### If logstash::ensure != present, purge config and sincedb directory 88 | file { $config_dir : 89 | ensure => 'absent', 90 | recurse => true, 91 | force => true, 92 | } 93 | 94 | file { $sincedb_dir : 95 | ensure => 'absent', 96 | recurse => true, 97 | force => true, 98 | } 99 | 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /spec/defines/output/logstash_output_http_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::output::http', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :content_type => 'value1', 13 | :exclude_tags => ['value2'], 14 | :fields => ['value3'], 15 | :format => 'json', 16 | :headers => { 'field5' => 'value5' }, 17 | :http_method => 'put', 18 | :mapping => { 'field7' => 'value7' }, 19 | :message => 'value8', 20 | :tags => ['value9'], 21 | :type => 'value10', 22 | :url => 'value11', 23 | :verify_ssl => false, 24 | } end 25 | 26 | it { should contain_file('/etc/logstash/agent/config/output_http_test').with(:content => "output {\n http {\n content_type => \"value1\"\n exclude_tags => ['value2']\n fields => ['value3']\n format => \"json\"\n headers => [\"field5\", \"value5\"]\n http_method => \"put\"\n mapping => [\"field7\", \"value7\"]\n message => \"value8\"\n tags => ['value9']\n type => \"value10\"\n url => \"value11\"\n verify_ssl => false\n }\n}\n") } 27 | end 28 | 29 | context "Instance test" do 30 | 31 | let :params do { 32 | :content_type => 'value1', 33 | :exclude_tags => ['value2'], 34 | :fields => ['value3'], 35 | :format => 'json', 36 | :headers => { 'field5' => 'value5' }, 37 | :http_method => 'put', 38 | :mapping => { 'field7' => 'value7' }, 39 | :message => 'value8', 40 | :tags => ['value9'], 41 | :type => 'value10', 42 | :url => 'value11', 43 | :verify_ssl => false, 44 | :instances => [ 'agent1', 'agent2' ] 45 | } end 46 | 47 | it { should contain_file('/etc/logstash/agent1/config/output_http_test') } 48 | it { should contain_file('/etc/logstash/agent2/config/output_http_test') } 49 | 50 | end 51 | 52 | context "Set file owner" do 53 | 54 | let(:facts) { {:operatingsystem => 'CentOS' }} 55 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 56 | let(:title) { 'test' } 57 | 58 | let :params do { 59 | :content_type => 'value1', 60 | :exclude_tags => ['value2'], 61 | :fields => ['value3'], 62 | :format => 'json', 63 | :headers => { 'field5' => 'value5' }, 64 | :http_method => 'put', 65 | :mapping => { 'field7' => 'value7' }, 66 | :message => 'value8', 67 | :tags => ['value9'], 68 | :type => 'value10', 69 | :url => 'value11', 70 | :verify_ssl => false, 71 | } end 72 | 73 | it { should contain_file('/etc/logstash/agent/config/output_http_test').with(:owner => 'logstash', :group => 'logstash') } 74 | 75 | end 76 | 77 | end 78 | -------------------------------------------------------------------------------- /spec/defines/output/logstash_output_sns_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::output::sns', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :access_key_id => 'value1', 13 | :arn => 'value2', 14 | :aws_credentials_file => 'value3', 15 | :exclude_tags => ['value4'], 16 | :fields => ['value5'], 17 | :format => 'json', 18 | :publish_boot_message_arn => 'value7', 19 | :region => 'us-east-1', 20 | :secret_access_key => 'value9', 21 | :tags => ['value10'], 22 | :type => 'value11', 23 | :use_ssl => false, 24 | } end 25 | 26 | it { should contain_file('/etc/logstash/agent/config/output_sns_test').with(:content => "output {\n sns {\n access_key_id => \"value1\"\n arn => \"value2\"\n aws_credentials_file => \"value3\"\n exclude_tags => ['value4']\n fields => ['value5']\n format => \"json\"\n publish_boot_message_arn => \"value7\"\n region => \"us-east-1\"\n secret_access_key => \"value9\"\n tags => ['value10']\n type => \"value11\"\n use_ssl => false\n }\n}\n") } 27 | end 28 | 29 | context "Instance test" do 30 | 31 | let :params do { 32 | :access_key_id => 'value1', 33 | :arn => 'value2', 34 | :aws_credentials_file => 'value3', 35 | :exclude_tags => ['value4'], 36 | :fields => ['value5'], 37 | :format => 'json', 38 | :publish_boot_message_arn => 'value7', 39 | :region => 'us-east-1', 40 | :secret_access_key => 'value9', 41 | :tags => ['value10'], 42 | :type => 'value11', 43 | :use_ssl => false, 44 | :instances => [ 'agent1', 'agent2' ] 45 | } end 46 | 47 | it { should contain_file('/etc/logstash/agent1/config/output_sns_test') } 48 | it { should contain_file('/etc/logstash/agent2/config/output_sns_test') } 49 | 50 | end 51 | 52 | context "Set file owner" do 53 | 54 | let(:facts) { {:operatingsystem => 'CentOS' }} 55 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 56 | let(:title) { 'test' } 57 | 58 | let :params do { 59 | :access_key_id => 'value1', 60 | :arn => 'value2', 61 | :aws_credentials_file => 'value3', 62 | :exclude_tags => ['value4'], 63 | :fields => ['value5'], 64 | :format => 'json', 65 | :publish_boot_message_arn => 'value7', 66 | :region => 'us-east-1', 67 | :secret_access_key => 'value9', 68 | :tags => ['value10'], 69 | :type => 'value11', 70 | :use_ssl => false, 71 | } end 72 | 73 | it { should contain_file('/etc/logstash/agent/config/output_sns_test').with(:owner => 'logstash', :group => 'logstash') } 74 | 75 | end 76 | 77 | end 78 | -------------------------------------------------------------------------------- /spec/defines/filter/logstash_filter_geoip_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::filter::geoip', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :add_tag => ['value2'], 14 | :database => 'puppet:///path/to/file3', 15 | :exclude_tags => ['value4'], 16 | :fields => ['value5'], 17 | :remove_tag => ['value6'], 18 | :source => 'value7', 19 | :tags => ['value8'], 20 | :type => 'value9', 21 | } end 22 | 23 | it { should contain_file('/etc/logstash/agent/config/filter_10_geoip_test').with(:content => "filter {\n geoip {\n add_field => [\"field1\", \"value1\"]\n add_tag => ['value2']\n database => \"/etc/logstash/files/filter/geoip/test/file3\"\n exclude_tags => ['value4']\n fields => ['value5']\n remove_tag => ['value6']\n source => \"value7\"\n tags => ['value8']\n type => \"value9\"\n }\n}\n") } 24 | it { should contain_file('/etc/logstash/files/filter/geoip/test/file3').with(:source => 'puppet:///path/to/file3') } 25 | it { should contain_file('/etc/logstash/files/filter/geoip/test') } 26 | it { should contain_exec('create_files_dir_filter_geoip_test').with(:command => 'mkdir -p /etc/logstash/files/filter/geoip/test') } 27 | end 28 | 29 | context "Instance test" do 30 | 31 | let :params do { 32 | :add_field => { 'field1' => 'value1' }, 33 | :add_tag => ['value2'], 34 | :database => 'puppet:///path/to/file3', 35 | :exclude_tags => ['value4'], 36 | :fields => ['value5'], 37 | :remove_tag => ['value6'], 38 | :source => 'value7', 39 | :tags => ['value8'], 40 | :type => 'value9', 41 | :instances => [ 'agent1', 'agent2' ] 42 | } end 43 | 44 | it { should contain_file('/etc/logstash/agent1/config/filter_10_geoip_test') } 45 | it { should contain_file('/etc/logstash/agent2/config/filter_10_geoip_test') } 46 | 47 | end 48 | 49 | context "Set file owner" do 50 | 51 | let(:facts) { {:operatingsystem => 'CentOS' }} 52 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 53 | let(:title) { 'test' } 54 | 55 | let :params do { 56 | :add_field => { 'field1' => 'value1' }, 57 | :add_tag => ['value2'], 58 | :database => 'puppet:///path/to/file3', 59 | :exclude_tags => ['value4'], 60 | :fields => ['value5'], 61 | :remove_tag => ['value6'], 62 | :source => 'value7', 63 | :tags => ['value8'], 64 | :type => 'value9', 65 | } end 66 | 67 | it { should contain_file('/etc/logstash/agent/config/filter_10_geoip_test').with(:owner => 'logstash', :group => 'logstash') } 68 | 69 | end 70 | 71 | end 72 | -------------------------------------------------------------------------------- /spec/defines/filter/logstash_filter_kv_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::filter::kv', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :add_tag => ['value2'], 14 | :exclude_tags => ['value3'], 15 | :field_split => 'value4', 16 | :fields => ['value5'], 17 | :prefix => 'value6', 18 | :remove_tag => ['value7'], 19 | :source => 'value8', 20 | :tags => ['value9'], 21 | :target => 'value10', 22 | :trim => 'value11', 23 | :type => 'value12', 24 | :value_split => 'value13', 25 | } end 26 | 27 | it { should contain_file('/etc/logstash/agent/config/filter_10_kv_test').with(:content => "filter {\n kv {\n add_field => [\"field1\", \"value1\"]\n add_tag => ['value2']\n exclude_tags => ['value3']\n field_split => \"value4\"\n fields => ['value5']\n prefix => \"value6\"\n remove_tag => ['value7']\n source => \"value8\"\n tags => ['value9']\n target => \"value10\"\n trim => \"value11\"\n type => \"value12\"\n value_split => \"value13\"\n }\n}\n") } 28 | end 29 | 30 | context "Instance test" do 31 | 32 | let :params do { 33 | :add_field => { 'field1' => 'value1' }, 34 | :add_tag => ['value2'], 35 | :exclude_tags => ['value3'], 36 | :field_split => 'value4', 37 | :fields => ['value5'], 38 | :prefix => 'value6', 39 | :remove_tag => ['value7'], 40 | :source => 'value8', 41 | :tags => ['value9'], 42 | :target => 'value10', 43 | :trim => 'value11', 44 | :type => 'value12', 45 | :value_split => 'value13', 46 | :instances => [ 'agent1', 'agent2' ] 47 | } end 48 | 49 | it { should contain_file('/etc/logstash/agent1/config/filter_10_kv_test') } 50 | it { should contain_file('/etc/logstash/agent2/config/filter_10_kv_test') } 51 | 52 | end 53 | 54 | context "Set file owner" do 55 | 56 | let(:facts) { {:operatingsystem => 'CentOS' }} 57 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 58 | let(:title) { 'test' } 59 | 60 | let :params do { 61 | :add_field => { 'field1' => 'value1' }, 62 | :add_tag => ['value2'], 63 | :exclude_tags => ['value3'], 64 | :field_split => 'value4', 65 | :fields => ['value5'], 66 | :prefix => 'value6', 67 | :remove_tag => ['value7'], 68 | :source => 'value8', 69 | :tags => ['value9'], 70 | :target => 'value10', 71 | :trim => 'value11', 72 | :type => 'value12', 73 | :value_split => 'value13', 74 | } end 75 | 76 | it { should contain_file('/etc/logstash/agent/config/filter_10_kv_test').with(:owner => 'logstash', :group => 'logstash') } 77 | 78 | end 79 | 80 | end 81 | -------------------------------------------------------------------------------- /spec/defines/input/logstash_input_zeromq_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::input::zeromq', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :address => ['value2'], 14 | :charset => 'ASCII-8BIT', 15 | :debug => false, 16 | :format => 'plain', 17 | :message_format => 'value6', 18 | :mode => 'server', 19 | :sender => 'value8', 20 | :sockopt => { 'field9' => 'value9' }, 21 | :tags => ['value10'], 22 | :topic => ['value11'], 23 | :topology => 'pushpull', 24 | :type => 'value13', 25 | } end 26 | 27 | it { should contain_file('/etc/logstash/agent/config/input_zeromq_test').with(:content => "input {\n zeromq {\n add_field => [\"field1\", \"value1\"]\n address => ['value2']\n charset => \"ASCII-8BIT\"\n debug => false\n format => \"plain\"\n message_format => \"value6\"\n mode => \"server\"\n sender => \"value8\"\n sockopt => [\"field9\", \"value9\"]\n tags => ['value10']\n topic => ['value11']\n topology => \"pushpull\"\n type => \"value13\"\n }\n}\n") } 28 | end 29 | 30 | context "Instance test" do 31 | 32 | let :params do { 33 | :add_field => { 'field1' => 'value1' }, 34 | :address => ['value2'], 35 | :charset => 'ASCII-8BIT', 36 | :debug => false, 37 | :format => 'plain', 38 | :message_format => 'value6', 39 | :mode => 'server', 40 | :sender => 'value8', 41 | :sockopt => { 'field9' => 'value9' }, 42 | :tags => ['value10'], 43 | :topic => ['value11'], 44 | :topology => 'pushpull', 45 | :type => 'value13', 46 | :instances => [ 'agent1', 'agent2' ] 47 | } end 48 | 49 | it { should contain_file('/etc/logstash/agent1/config/input_zeromq_test') } 50 | it { should contain_file('/etc/logstash/agent2/config/input_zeromq_test') } 51 | 52 | end 53 | 54 | context "Set file owner" do 55 | 56 | let(:facts) { {:operatingsystem => 'CentOS' }} 57 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 58 | let(:title) { 'test' } 59 | 60 | let :params do { 61 | :add_field => { 'field1' => 'value1' }, 62 | :address => ['value2'], 63 | :charset => 'ASCII-8BIT', 64 | :debug => false, 65 | :format => 'plain', 66 | :message_format => 'value6', 67 | :mode => 'server', 68 | :sender => 'value8', 69 | :sockopt => { 'field9' => 'value9' }, 70 | :tags => ['value10'], 71 | :topic => ['value11'], 72 | :topology => 'pushpull', 73 | :type => 'value13', 74 | } end 75 | 76 | it { should contain_file('/etc/logstash/agent/config/input_zeromq_test').with(:owner => 'logstash', :group => 'logstash') } 77 | 78 | end 79 | 80 | end 81 | -------------------------------------------------------------------------------- /spec/defines/filter/logstash_filter_prune_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::filter::prune', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :add_tag => ['value2'], 14 | :blacklist_names => ['value3'], 15 | :blacklist_values => { 'field4' => 'value4' }, 16 | :exclude_tags => ['value5'], 17 | :interpolate => false, 18 | :remove_tag => ['value7'], 19 | :tags => ['value8'], 20 | :type => 'value9', 21 | :whitelist_names => ['value10'], 22 | :whitelist_values => { 'field11' => 'value11' }, 23 | } end 24 | 25 | it { should contain_file('/etc/logstash/agent/config/filter_10_prune_test').with(:content => "filter {\n prune {\n add_field => [\"field1\", \"value1\"]\n add_tag => ['value2']\n blacklist_names => ['value3']\n blacklist_values => [\"field4\", \"value4\"]\n exclude_tags => ['value5']\n interpolate => false\n remove_tag => ['value7']\n tags => ['value8']\n type => \"value9\"\n whitelist_names => ['value10']\n whitelist_values => [\"field11\", \"value11\"]\n }\n}\n") } 26 | end 27 | 28 | context "Instance test" do 29 | 30 | let :params do { 31 | :add_field => { 'field1' => 'value1' }, 32 | :add_tag => ['value2'], 33 | :blacklist_names => ['value3'], 34 | :blacklist_values => { 'field4' => 'value4' }, 35 | :exclude_tags => ['value5'], 36 | :interpolate => false, 37 | :remove_tag => ['value7'], 38 | :tags => ['value8'], 39 | :type => 'value9', 40 | :whitelist_names => ['value10'], 41 | :whitelist_values => { 'field11' => 'value11' }, 42 | :instances => [ 'agent1', 'agent2' ] 43 | } end 44 | 45 | it { should contain_file('/etc/logstash/agent1/config/filter_10_prune_test') } 46 | it { should contain_file('/etc/logstash/agent2/config/filter_10_prune_test') } 47 | 48 | end 49 | 50 | context "Set file owner" do 51 | 52 | let(:facts) { {:operatingsystem => 'CentOS' }} 53 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 54 | let(:title) { 'test' } 55 | 56 | let :params do { 57 | :add_field => { 'field1' => 'value1' }, 58 | :add_tag => ['value2'], 59 | :blacklist_names => ['value3'], 60 | :blacklist_values => { 'field4' => 'value4' }, 61 | :exclude_tags => ['value5'], 62 | :interpolate => false, 63 | :remove_tag => ['value7'], 64 | :tags => ['value8'], 65 | :type => 'value9', 66 | :whitelist_names => ['value10'], 67 | :whitelist_values => { 'field11' => 'value11' }, 68 | } end 69 | 70 | it { should contain_file('/etc/logstash/agent/config/filter_10_prune_test').with(:owner => 'logstash', :group => 'logstash') } 71 | 72 | end 73 | 74 | end 75 | -------------------------------------------------------------------------------- /spec/defines/input/logstash_input_irc_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::input::irc', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :add_field => { 'field1' => 'value1' }, 13 | :channels => ['value2'], 14 | :charset => 'ASCII-8BIT', 15 | :debug => false, 16 | :format => 'plain', 17 | :host => 'value6', 18 | :message_format => 'value7', 19 | :nick => 'value8', 20 | :password => 'value9', 21 | :port => 10, 22 | :real => 'value11', 23 | :secure => false, 24 | :tags => ['value13'], 25 | :type => 'value14', 26 | :user => 'value15', 27 | } end 28 | 29 | it { should contain_file('/etc/logstash/agent/config/input_irc_test').with(:content => "input {\n irc {\n add_field => [\"field1\", \"value1\"]\n channels => ['value2']\n charset => \"ASCII-8BIT\"\n debug => false\n format => \"plain\"\n host => \"value6\"\n message_format => \"value7\"\n nick => \"value8\"\n password => \"value9\"\n port => 10\n real => \"value11\"\n secure => false\n tags => ['value13']\n type => \"value14\"\n user => \"value15\"\n }\n}\n") } 30 | end 31 | 32 | context "Instance test" do 33 | 34 | let :params do { 35 | :add_field => { 'field1' => 'value1' }, 36 | :channels => ['value2'], 37 | :charset => 'ASCII-8BIT', 38 | :debug => false, 39 | :format => 'plain', 40 | :host => 'value6', 41 | :message_format => 'value7', 42 | :nick => 'value8', 43 | :password => 'value9', 44 | :port => 10, 45 | :real => 'value11', 46 | :secure => false, 47 | :tags => ['value13'], 48 | :type => 'value14', 49 | :user => 'value15', 50 | :instances => [ 'agent1', 'agent2' ] 51 | } end 52 | 53 | it { should contain_file('/etc/logstash/agent1/config/input_irc_test') } 54 | it { should contain_file('/etc/logstash/agent2/config/input_irc_test') } 55 | 56 | end 57 | 58 | context "Set file owner" do 59 | 60 | let(:facts) { {:operatingsystem => 'CentOS' }} 61 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 62 | let(:title) { 'test' } 63 | 64 | let :params do { 65 | :add_field => { 'field1' => 'value1' }, 66 | :channels => ['value2'], 67 | :charset => 'ASCII-8BIT', 68 | :debug => false, 69 | :format => 'plain', 70 | :host => 'value6', 71 | :message_format => 'value7', 72 | :nick => 'value8', 73 | :password => 'value9', 74 | :port => 10, 75 | :real => 'value11', 76 | :secure => false, 77 | :tags => ['value13'], 78 | :type => 'value14', 79 | :user => 'value15', 80 | } end 81 | 82 | it { should contain_file('/etc/logstash/agent/config/input_irc_test').with(:owner => 'logstash', :group => 'logstash') } 83 | 84 | end 85 | 86 | end 87 | -------------------------------------------------------------------------------- /spec/defines/output/logstash_output_statsd_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'logstash::output::statsd', :type => 'define' do 4 | 5 | let(:facts) { {:operatingsystem => 'CentOS' }} 6 | let(:pre_condition) { 'class {"logstash": }'} 7 | let(:title) { 'test' } 8 | 9 | context "Input test" do 10 | 11 | let :params do { 12 | :count => { 'field1' => 'value1' }, 13 | :debug => false, 14 | :decrement => ['value3'], 15 | :exclude_tags => ['value4'], 16 | :fields => ['value5'], 17 | :host => 'value6', 18 | :increment => ['value7'], 19 | :namespace => 'value8', 20 | :port => 9, 21 | :sample_rate => 10, 22 | :sender => 'value11', 23 | :tags => ['value12'], 24 | :timing => { 'field13' => 'value13' }, 25 | :type => 'value14', 26 | } end 27 | 28 | it { should contain_file('/etc/logstash/agent/config/output_statsd_test').with(:content => "output {\n statsd {\n count => [\"field1\", \"value1\"]\n debug => false\n decrement => ['value3']\n exclude_tags => ['value4']\n fields => ['value5']\n host => \"value6\"\n increment => ['value7']\n namespace => \"value8\"\n port => 9\n sample_rate => 10\n sender => \"value11\"\n tags => ['value12']\n timing => [\"field13\", \"value13\"]\n type => \"value14\"\n }\n}\n") } 29 | end 30 | 31 | context "Instance test" do 32 | 33 | let :params do { 34 | :count => { 'field1' => 'value1' }, 35 | :debug => false, 36 | :decrement => ['value3'], 37 | :exclude_tags => ['value4'], 38 | :fields => ['value5'], 39 | :host => 'value6', 40 | :increment => ['value7'], 41 | :namespace => 'value8', 42 | :port => 9, 43 | :sample_rate => 10, 44 | :sender => 'value11', 45 | :tags => ['value12'], 46 | :timing => { 'field13' => 'value13' }, 47 | :type => 'value14', 48 | :instances => [ 'agent1', 'agent2' ] 49 | } end 50 | 51 | it { should contain_file('/etc/logstash/agent1/config/output_statsd_test') } 52 | it { should contain_file('/etc/logstash/agent2/config/output_statsd_test') } 53 | 54 | end 55 | 56 | context "Set file owner" do 57 | 58 | let(:facts) { {:operatingsystem => 'CentOS' }} 59 | let(:pre_condition) { 'class {"logstash": logstash_user => "logstash", logstash_group => "logstash" }'} 60 | let(:title) { 'test' } 61 | 62 | let :params do { 63 | :count => { 'field1' => 'value1' }, 64 | :debug => false, 65 | :decrement => ['value3'], 66 | :exclude_tags => ['value4'], 67 | :fields => ['value5'], 68 | :host => 'value6', 69 | :increment => ['value7'], 70 | :namespace => 'value8', 71 | :port => 9, 72 | :sample_rate => 10, 73 | :sender => 'value11', 74 | :tags => ['value12'], 75 | :timing => { 'field13' => 'value13' }, 76 | :type => 'value14', 77 | } end 78 | 79 | it { should contain_file('/etc/logstash/agent/config/output_statsd_test').with(:owner => 'logstash', :group => 'logstash') } 80 | 81 | end 82 | 83 | end 84 | --------------------------------------------------------------------------------