Index: modules/logstash/manifests/pipeline.pp |
diff --git a/modules/logstash/manifests/pipeline.pp b/modules/logstash/manifests/pipeline.pp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..7d16cee2a528960e63c79b68bcdaa3c27be29371 |
--- /dev/null |
+++ b/modules/logstash/manifests/pipeline.pp |
@@ -0,0 +1,87 @@ |
+# == Type: logstash::pipeline |
+# |
+# Manage Logstash (https://logstash.net/) pipeline configuration files. |
+# |
+# While one can directly provide the configuration $source or $content, one |
+# should note that a logstash::pipeline resource is actually the head of the |
+# logfile for concatenation (analogous to file_concat or module concat). Use |
+# logstash::fragment to assemble such a file from multiple resources. |
+# |
+# === Parameters: |
+# |
+# [*content*] |
+# The configuration as-is, mutually exclusive with $source. |
+# |
+# [*description*] |
+# If both $content and $source are undef, $description is converted into |
+# a comment header (prefixed by #) for the pipeline configuration, which |
+# is then expected to be setup further via logstash::fragment. |
+# |
+# [*ensure*] |
+# Either 'present' or 'absent'. |
+# |
+# [*source*] |
+# The configuration source location, mutually exclusive with $content. |
+# |
+# === Examples: |
+# |
+# Below please find a list of examples on how to use this type. Examples |
+# on howto configure a Logstash pipeline are provided by Elastic at |
Felix Dahlke
2015/10/07 10:46:32
Nit: "how to"
mathias
2015/10/20 13:03:34
Done.
|
+# https://www.elastic.co/guide/en/logstash/current/config-examples.html |
+# |
+# logstash::pipeline {'alpha': |
+# description => 'A pipeline setup using logstash::fragment', |
+# ensure => 'present', |
+# } |
+# |
+# logstash::pipeline {'beta': |
+# description => 'A pipeline setup from a single template', |
+# content => template('custom/pipeline.erb'), |
+# } |
+# |
+# logstash::pipeline {'gamma': |
+# description => 'An obsolete setup to be removed if present', |
+# ensure => 'absent', |
+# } |
+# |
+# For more information on howto use logstash::fragment with a pipeline |
Felix Dahlke
2015/10/07 10:46:32
Nit: "how to"
mathias
2015/10/20 13:03:34
Done.
|
+# like 'alpha' above can be found in the accompanying fragment.pp file. |
+# |
+define logstash::pipeline( |
+ $content = undef, |
+ $description = "Puppet: Logstash::Pipeline['$title']", |
+ $ensure = 'present', |
+ $source = undef, |
+) { |
+ |
+ $id = "logstash::pipeline#$title" |
+ $path = sprintf("/etc/logstash/conf.d/puppet-%s.conf", uriescape($title)) |
+ |
+ if $ensure !~ /^(absent|purged)$/ { |
+ |
+ concat {$id: |
+ notify => Service['logstash'], |
+ path => $path, |
+ require => Package['logstash'], |
+ } |
+ |
+ concat::fragment {$id: |
+ content => $content ? { |
+ undef => $source ? { |
+ undef => sprintf("# %s\n\n", join("\n# ", split($description, "\n"))), |
Felix Dahlke
2015/10/07 10:46:33
Why do we add anything if there's neither content
mathias
2015/10/20 13:03:34
One must supply either $content or $source for con
|
+ default => undef, |
+ }, |
+ default => $content, |
+ }, |
+ order => 0, |
+ source => $source, |
+ target => $id, |
+ } |
+ } |
+ elsif !defined(File[$path]) { |
+ |
+ file {$path: |
+ ensure => 'absent', |
+ } |
+ } |
+} |