Left: | ||
Right: |
OLD | NEW |
---|---|
(Empty) | |
1 # == Type: logstash::pipeline | |
2 # | |
3 # Manage Logstash (https://logstash.net/) pipeline configuration files. | |
4 # | |
5 # While one can directly provide the configuration $source or $content, one | |
6 # should note that a logstash::pipeline resource is actually the head of the | |
7 # logfile for concatenation (analogous to file_concat or module concat). Use | |
8 # logstash::fragment to assemble such a file from multiple resources. | |
9 # | |
10 # === Parameters: | |
11 # | |
12 # [*content*] | |
13 # The configuration as-is, mutually exclusive with $source. | |
14 # | |
15 # [*description*] | |
16 # If both $content and $source are undef, $description is converted into | |
17 # a comment header (prefixed by #) for the pipeline configuration, which | |
18 # is then expected to be setup further via logstash::fragment. | |
19 # | |
20 # [*ensure*] | |
21 # Either 'present' or 'absent'. | |
22 # | |
23 # [*source*] | |
24 # The configuration source location, mutually exclusive with $content. | |
25 # | |
26 # === Examples: | |
27 # | |
28 # Below please find a list of examples on how to use this type. Examples | |
29 # 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.
| |
30 # https://www.elastic.co/guide/en/logstash/current/config-examples.html | |
31 # | |
32 # logstash::pipeline {'alpha': | |
33 # description => 'A pipeline setup using logstash::fragment', | |
34 # ensure => 'present', | |
35 # } | |
36 # | |
37 # logstash::pipeline {'beta': | |
38 # description => 'A pipeline setup from a single template', | |
39 # content => template('custom/pipeline.erb'), | |
40 # } | |
41 # | |
42 # logstash::pipeline {'gamma': | |
43 # description => 'An obsolete setup to be removed if present', | |
44 # ensure => 'absent', | |
45 # } | |
46 # | |
47 # 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.
| |
48 # like 'alpha' above can be found in the accompanying fragment.pp file. | |
49 # | |
50 define logstash::pipeline( | |
51 $content = undef, | |
52 $description = "Puppet: Logstash::Pipeline['$title']", | |
53 $ensure = 'present', | |
54 $source = undef, | |
55 ) { | |
56 | |
57 $id = "logstash::pipeline#$title" | |
58 $path = sprintf("/etc/logstash/conf.d/puppet-%s.conf", uriescape($title)) | |
59 | |
60 if $ensure !~ /^(absent|purged)$/ { | |
61 | |
62 concat {$id: | |
63 notify => Service['logstash'], | |
64 path => $path, | |
65 require => Package['logstash'], | |
66 } | |
67 | |
68 concat::fragment {$id: | |
69 content => $content ? { | |
70 undef => $source ? { | |
71 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
| |
72 default => undef, | |
73 }, | |
74 default => $content, | |
75 }, | |
76 order => 0, | |
77 source => $source, | |
78 target => $id, | |
79 } | |
80 } | |
81 elsif !defined(File[$path]) { | |
82 | |
83 file {$path: | |
84 ensure => 'absent', | |
85 } | |
86 } | |
87 } | |
OLD | NEW |