|
1 | 1 | # == define: logstash::configfile
|
2 | 2 | #
|
3 |
| -# This define is to manage the config files for Logstah |
| 3 | +# This define is to manage the pipeline config files for Logstash |
4 | 4 | #
|
5 | 5 | # === Parameters
|
6 | 6 | #
|
7 | 7 | # [*content*]
|
8 |
| -# Supply content to be used for the config file. This can also be a template. |
| 8 | +# Supply content to be used for the config file, possibly rendered with |
| 9 | +# template(). |
9 | 10 | #
|
10 | 11 | # [*source*]
|
11 |
| -# Supply a puppet file resource to be used for the config file. |
12 |
| -# |
13 |
| -# [*order*] |
14 |
| -# The order number controls in which sequence the config file fragments are concatenated. |
| 12 | +# Supply a file resource to be used for the config file. |
15 | 13 | #
|
16 | 14 | # === Examples
|
17 | 15 | #
|
18 | 16 | # Set config file content with a literal value:
|
19 | 17 | #
|
20 |
| -# logstash::configfile { 'apache': |
21 |
| -# content => "", |
22 |
| -# order => 10 |
| 18 | +# logstash::configfile { 'heartbeat': |
| 19 | +# content => 'input { heartbeat {} }', |
23 | 20 | # }
|
24 | 21 | #
|
25 |
| -# or with a puppet file source: |
| 22 | +# or with a file source: |
26 | 23 | #
|
27 | 24 | # logstash::configfile { 'apache':
|
28 | 25 | # source => 'puppet://path/to/apache.conf',
|
29 |
| -# order => 10 |
30 |
| -# } |
31 |
| -# |
32 |
| -# or with template (useful with Hiera): |
33 |
| -# |
34 |
| -# logstash::configfile { 'apache': |
35 |
| -# template => "${module_name}/path/to/apache.conf.erb", |
36 |
| -# order => 10 |
37 | 26 | # }
|
38 | 27 | #
|
39 | 28 | # === Authors
|
40 | 29 | #
|
41 |
| -# * Richard Pijnenburg <mailto:richard.pijnenburg@elasticsearch.com> |
| 30 | +# https://github.com/elastic/puppet-logstash/graphs/contributors |
42 | 31 | #
|
43 |
| -define logstash::configfile( |
44 |
| - $content = undef, |
45 |
| - $source = undef, |
46 |
| - $order = 10, |
47 |
| - $template = undef, |
48 |
| -) { |
| 32 | +define logstash::configfile($content = undef, $source = undef) { |
| 33 | + include logstash |
49 | 34 |
|
50 |
| - if ($template != undef ) { |
51 |
| - $config_content = template($template) |
52 |
| - } |
53 |
| - else { |
54 |
| - $config_content = $content |
55 |
| - } |
| 35 | + $path = "/etc/logstash/conf.d/${name}.conf" |
| 36 | + $owner = $logstash::logstash_user |
| 37 | + $group = $logstash::logstash_group |
| 38 | + $mode ='0440' |
| 39 | + $require = Package['logstash'] # So that we have '/etc/logstash/conf.d'. |
| 40 | + $tag = [ 'logstash_config' ] # So that we notify the service. |
56 | 41 |
|
57 |
| - file_fragment { $name: |
58 |
| - tag => "LS_CONFIG_${::fqdn}", |
59 |
| - content => $config_content, |
60 |
| - source => $source, |
61 |
| - order => $order, |
62 |
| - before => [ File_concat['ls-config'] ], |
| 42 | + if($content){ |
| 43 | + file { $path: |
| 44 | + content => $content, |
| 45 | + owner => $owner, |
| 46 | + group => $group, |
| 47 | + mode => $mode, |
| 48 | + require => $require, |
| 49 | + tag => $tag, |
| 50 | + } |
| 51 | + } |
| 52 | + elsif($source){ |
| 53 | + file { $path: |
| 54 | + source => $source, |
| 55 | + owner => $owner, |
| 56 | + group => $group, |
| 57 | + mode => $mode, |
| 58 | + require => $require, |
| 59 | + tag => $tag, |
| 60 | + } |
63 | 61 | }
|
64 | 62 | }
|
0 commit comments