Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes #388 #389

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,37 @@ my_logstash_configs:
In this example, templates for the config files are stored in the custom,
site-specific module "`site_logstash`".

You can also use the `pipeline_files` class within an ENC to generate pipeline configuration files:

```yaml
---
pipeline1:
content: 'input {} filter {} output {}'
```

Or, with a specific destination file path:

```yaml
---
pipeline2:
path: /etc/logstash/pipelines.d/pipeline2.pipeline
content: 'input {} filter {} output {}'
```

`content` can also span multiple lines:

```yaml
---
pipeline2.pipeline:
content: |
input {
syslog {}
}
output {
elasticsearch {}
}
```

### Patterns
Many plugins (notably [Grok](http://logstash.net/docs/latest/filters/grok)) use *patterns*. While many are included in Logstash already, additional site-specific patterns can be managed as well.

Expand Down
2 changes: 2 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@
$startup_options = {},
$jvm_options = [],
Array $pipelines = [],
Hash $pipeline_files = {},
Boolean $manage_repo = true,
)
{
Expand All @@ -171,4 +172,5 @@
include logstash::package
include logstash::config
include logstash::service
include logstash::pipeline_files
}
29 changes: 29 additions & 0 deletions manifests/pipeline_files.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This class manages pipeline configuration files for Logstash.
#
# @example Include this class to ensure its resources are available.
# include logstash::pipeline_files
#
# @example Pass values to this class using an ENC with a specific path
# pipeline2:
# path: "/etc/logstash/conf.d/pipeline2.pipeline"
# content: pipeline2
#
# @example Pass values to this class using an ENC without a specific path
# pipeline2:
# content: pipeline2
#
# @author https://github.com/XeonFibre
#
class logstash::pipeline_files {

$pipeline_files = $logstash::pipeline_files

if(!empty($pipeline_files)) {
$pipeline_files.each |String $id, Hash $attributes| {
logstash::configfile { $id:
content => $attributes[content],
path => $attributes[path],
}
}
}
}
41 changes: 41 additions & 0 deletions spec/acceptance/class_logstash_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,47 @@
end
end

describe 'pipeline_files_parameter' do
context "with specific config path declared" do
before(:context) do
pipeline_files_puppet = <<-END
{ "logstash-pipeline1.conf" =>
{
"path" => "/etc/logstash/conf.d/logstash-pipeline1.conf",
"content" => "My config"
}
}
END
install_logstash_from_local_file("pipeline_files => #{pipeline_files_puppet}")
end

it 'should render them to /etc/logstash/conf.d/logstash-pipeline1.conf' do
result = shell('cat /etc/logstash/conf.d/logstash-pipeline1.conf').stdout
expect(result).to eq("My config")
end

end

context "without specific config path declared" do
before(:context) do
pipeline_files_puppet = <<-END
{ "logstash-pipeline2.conf" =>
{
"content" => "My config"
}
}
END
install_logstash_from_local_file("pipeline_files => #{pipeline_files_puppet}")
end

it 'should render them to /etc/logstash/conf.d/logstash-pipeline2.conf' do
result = shell('cat /etc/logstash/conf.d/logstash-pipeline2.conf').stdout
expect(result).to eq("My config")
end

end
end

describe 'xpack_management_enabled_parameter' do
context 'when set true with dotted notation' do
before(:context) do
Expand Down