Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: modules/logstash/manifests/pipeline.pp

Issue 29327588: Issue 2864 - Introduce class logstash (Closed)
Left Patch Set: Created Sept. 14, 2015, 7:23 a.m.
Right Patch Set: Issue 2864 - Address feedback from code-review Created Oct. 20, 2015, 1:04 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « modules/logstash/manifests/init.pp ('k') | modules/logstash/templates/elastic-logstash-gpg-key.erb » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # == Type: logstash::pipeline 1 # == Type: logstash::pipeline
2 # 2 #
3 # Manage Logstash (https://logstash.net/) pipeline configuration files. 3 # Manage Logstash (https://logstash.net/) pipeline configuration files.
4 # 4 #
5 # While one can directly provide the configuration $source or $content, one 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 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 7 # logfile for concatenation (analogous to file_concat or module concat). Use
8 # logstash::fragment to assemble such a file from multiple resources. 8 # logstash::fragment to assemble such a file from multiple resources.
9 # 9 #
10 # === Parameters: 10 # === Parameters:
11 # 11 #
12 # [*content*] 12 # [*content*]
13 # The configuration as-is, mutually exclusive with $source. 13 # The configuration as-is, mutually exclusive with $source.
14 # 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*] 15 # [*ensure*]
21 # Either 'present' or 'absent'. 16 # Either 'present' or 'absent'.
22 # 17 #
23 # [*source*] 18 # [*source*]
24 # The configuration source location, mutually exclusive with $content. 19 # The configuration source location, mutually exclusive with $content.
25 # 20 #
26 # === Examples: 21 # === Examples:
27 # 22 #
28 # Below please find a list of examples on how to use this type. Examples 23 # 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 24 # on how to 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 25 # https://www.elastic.co/guide/en/logstash/current/config-examples.html
31 # 26 #
27 # # A pipeline setup using logstash::fragment
32 # logstash::pipeline {'alpha': 28 # logstash::pipeline {'alpha':
33 # description => 'A pipeline setup using logstash::fragment',
34 # ensure => 'present', 29 # ensure => 'present',
35 # } 30 # }
36 # 31 #
32 # # A pipeline setup from a single template
37 # logstash::pipeline {'beta': 33 # logstash::pipeline {'beta':
38 # description => 'A pipeline setup from a single template',
39 # content => template('custom/pipeline.erb'), 34 # content => template('custom/pipeline.erb'),
40 # } 35 # }
41 # 36 #
37 # # An obsolete setup to be removed if present
42 # logstash::pipeline {'gamma': 38 # logstash::pipeline {'gamma':
43 # description => 'An obsolete setup to be removed if present',
44 # ensure => 'absent', 39 # ensure => 'absent',
45 # } 40 # }
46 # 41 #
47 # For more information on howto use logstash::fragment with a pipeline 42 # For more information on how to 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. 43 # like 'alpha' above please refer to the accompanying fragment.pp file.
49 # 44 #
50 define logstash::pipeline( 45 define logstash::pipeline(
51 $content = undef, 46 $content = undef,
52 $description = "Puppet: Logstash::Pipeline['$title']",
53 $ensure = 'present', 47 $ensure = 'present',
54 $source = undef, 48 $source = undef,
55 ) { 49 ) {
56 50
57 $id = "logstash::pipeline#$title" 51 $id = "logstash::pipeline#$title"
58 $path = sprintf("/etc/logstash/conf.d/puppet-%s.conf", uriescape($title)) 52 $path = sprintf("/etc/logstash/conf.d/puppet-%s.conf", uriescape($title))
59 53
60 if $ensure !~ /^(absent|purged)$/ { 54 if $ensure !~ /^(absent|purged)$/ {
61 55
62 concat {$id: 56 concat {$id:
63 notify => Service['logstash'], 57 notify => Service['logstash'],
64 path => $path, 58 path => $path,
65 require => Package['logstash'], 59 require => Package['logstash'],
66 } 60 }
67 61
68 concat::fragment {$id: 62 concat::fragment {$id:
69 content => $content ? { 63 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, 64 order => 0,
77 source => $source, 65 source => $source,
78 target => $id, 66 target => $id,
79 } 67 }
80 } 68 }
81 elsif !defined(File[$path]) { 69 elsif !defined(File[$path]) {
82 70
83 file {$path: 71 file {$path:
84 ensure => 'absent', 72 ensure => 'absent',
85 } 73 }
86 } 74 }
87 } 75 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld