-
-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2ea7121
commit 054248c
Showing
11 changed files
with
84 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Test output configuration with null output. | ||
output { | ||
null {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,62 @@ | ||
# == define: logstash::configfile | ||
# | ||
# This define is to manage the config files for Logstah | ||
# This define is to manage the pipeline config files for Logstash | ||
# | ||
# === Parameters | ||
# | ||
# [*content*] | ||
# Supply content to be used for the config file. This can also be a template. | ||
# Supply content to be used for the config file, possibly rendered with | ||
# template(). | ||
# | ||
# [*source*] | ||
# Supply a puppet file resource to be used for the config file. | ||
# | ||
# [*order*] | ||
# The order number controls in which sequence the config file fragments are concatenated. | ||
# Supply a file resource to be used for the config file. | ||
# | ||
# === Examples | ||
# | ||
# Set config file content with a literal value: | ||
# | ||
# logstash::configfile { 'apache': | ||
# content => "", | ||
# order => 10 | ||
# logstash::configfile { 'heartbeat': | ||
# content => 'input { heartbeat {} }', | ||
# } | ||
# | ||
# or with a puppet file source: | ||
# or with a file source: | ||
# | ||
# logstash::configfile { 'apache': | ||
# source => 'puppet://path/to/apache.conf', | ||
# order => 10 | ||
# } | ||
# | ||
# or with template (useful with Hiera): | ||
# | ||
# logstash::configfile { 'apache': | ||
# template => "${module_name}/path/to/apache.conf.erb", | ||
# order => 10 | ||
# } | ||
# | ||
# === Authors | ||
# | ||
# * Richard Pijnenburg <mailto:richard.pijnenburg@elasticsearch.com> | ||
# https://github.com/elastic/puppet-logstash/graphs/contributors | ||
# | ||
define logstash::configfile( | ||
$content = undef, | ||
$source = undef, | ||
$order = 10, | ||
$template = undef, | ||
) { | ||
define logstash::configfile($content = undef, $source = undef) { | ||
include logstash | ||
|
||
if ($template != undef ) { | ||
$config_content = template($template) | ||
} | ||
else { | ||
$config_content = $content | ||
} | ||
$path = "/etc/logstash/conf.d/${name}.conf" | ||
$owner = $logstash::logstash_user | ||
$group = $logstash::logstash_group | ||
$mode ='0440' | ||
$require = Package['logstash'] # So that we have '/etc/logstash/conf.d'. | ||
$tag = [ 'logstash_config' ] # So that we notify the service. | ||
|
||
file_fragment { $name: | ||
tag => "LS_CONFIG_${::fqdn}", | ||
content => $config_content, | ||
source => $source, | ||
order => $order, | ||
before => [ File_concat['ls-config'] ], | ||
if($content){ | ||
file { $path: | ||
content => $content, | ||
owner => $owner, | ||
group => $group, | ||
mode => $mode, | ||
require => $require, | ||
tag => $tag, | ||
} | ||
} | ||
elsif($source){ | ||
file { $path: | ||
source => $source, | ||
owner => $owner, | ||
group => $group, | ||
mode => $mode, | ||
require => $require, | ||
tag => $tag, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
require 'spec_helper_acceptance' | ||
|
||
describe 'define logstash::configfile' do | ||
context 'with explicit content' do | ||
logstash_config = 'input { heartbeat {} }' | ||
|
||
manifest = <<-END | ||
logstash::configfile { 'heartbeat-input': | ||
content => '#{logstash_config}' | ||
} | ||
END | ||
|
||
before(:context) do | ||
apply_manifest(manifest, catch_failures: true) | ||
end | ||
|
||
it 'creates a file with the given content' do | ||
result = shell('cat /etc/logstash/conf.d/heartbeat-input.conf').stdout | ||
expect(result).to eq(logstash_config) | ||
end | ||
end | ||
|
||
context 'with a puppet:// url as source parameter' do | ||
manifest = <<-END | ||
logstash::configfile { 'null-output': | ||
source => 'puppet:///modules/logstash/null-output.conf' | ||
} | ||
END | ||
|
||
before(:context) do | ||
apply_manifest(manifest, catch_failures: true) | ||
end | ||
|
||
it 'places the config file' do | ||
result = shell('cat /etc/logstash/conf.d/null-output.conf').stdout | ||
expect(result).to include('Test output configuration with null output.') | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters