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 # [*ensure*] | |
16 # Either 'present' or 'absent'. | |
17 # | |
18 # [*source*] | |
19 # The configuration source location, mutually exclusive with $content. | |
20 # | |
21 # === Examples: | |
22 # | |
23 # Below please find a list of examples on how to use this type. Examples | |
24 # on how to configure a Logstash pipeline are provided by Elastic at | |
25 # https://www.elastic.co/guide/en/logstash/current/config-examples.html | |
26 # | |
27 # # A pipeline setup using logstash::fragment | |
28 # logstash::pipeline {'alpha': | |
29 # ensure => 'present', | |
30 # } | |
31 # | |
32 # # A pipeline setup from a single template | |
33 # logstash::pipeline {'beta': | |
34 # content => template('custom/pipeline.erb'), | |
35 # } | |
36 # | |
37 # # An obsolete setup to be removed if present | |
38 # logstash::pipeline {'gamma': | |
39 # ensure => 'absent', | |
40 # } | |
41 # | |
42 # For more information on how to use logstash::fragment with a pipeline | |
43 # like 'alpha' above please refer to the accompanying fragment.pp file. | |
44 # | |
45 define logstash::pipeline( | |
46 $content = undef, | |
47 $ensure = 'present', | |
48 $source = undef, | |
49 ) { | |
50 | |
51 $id = "logstash::pipeline#$title" | |
52 $path = sprintf("/etc/logstash/conf.d/puppet-%s.conf", uriescape($title)) | |
53 | |
54 if $ensure !~ /^(absent|purged)$/ { | |
55 | |
56 concat {$id: | |
57 notify => Service['logstash'], | |
58 path => $path, | |
59 require => Package['logstash'], | |
60 } | |
61 | |
62 concat::fragment {$id: | |
63 content => $content, | |
64 order => 0, | |
65 source => $source, | |
66 target => $id, | |
67 } | |
68 } | |
69 elsif !defined(File[$path]) { | |
70 | |
71 file {$path: | |
72 ensure => 'absent', | |
73 } | |
74 } | |
75 } | |
OLD | NEW |