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

Side by Side Diff: modules/logstash/manifests/init.pp

Issue 29327588: Issue 2864 - Introduce class logstash (Closed)
Patch Set: Created Sept. 14, 2015, 7:23 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # == Class: logstash
2 #
3 # Manage Logstash (https://logstash.net/) installations via APT.
4 #
5 # Please refer to the online documentation at Elastic for more information
6 # on the logstash software, it's usage and configuration options:
7 #
8 # https://www.elastic.co/guide/en/logstash/current/index.html
9 #
10 # === Parameters:
11 #
12 # [*contrib*]
13 # Whether to realize Package['logstash-contrib'].
14 #
15 # [*ensure*]
16 # Either 'present'/'stopped', 'running'/'started', or 'absent'/'purged'.
17 # Note that Service['logstash'] is only realized implicitly when $ensure
18 # is neither 'absent' nor 'purged'.
19 #
20 # [*pipelines*]
21 # A hash to setup logstash::pipeline {$name: $parameter} resources.
22 #
23 # [*version*]
24 # The http://packages.elasticsearch.org/logstash/%s/debian $version.
25 #
26 # === Examples:
27 #
28 # class {'logstash':
29 # contrib => true,
30 # pipelines => {
31 # 'example' => {
32 # # see type logstash::pipeline for a parameter reference
33 # },
34 # },
35 # }
36 #
37 class logstash (
38 $contrib = false,
39 $ensure = 'running',
40 $pipelines = {},
41 $version = '1.4',
42 ) {
43
44 $ensure_file = $ensure ? {
45 /^(absent|purged)$/ => 'absent',
46 default => 'present',
47 }
48
49 apt::key {'logstash':
50 ensure => $ensure_file,
51 key => 'D88E42B4',
52 key_content => template('logstash/elastic-logstash-gpg-key.erb'),
53 }
54
55 apt::source {'logstash':
56 ensure => $ensure_file,
57 include_src => false,
58 location => "http://packages.elasticsearch.org/logstash/$version/debian",
Felix Dahlke 2015/10/07 10:46:32 Can we use HTTPS?
mathias 2015/10/20 13:03:33 Yes we can.
59 release => 'stable',
60 require => Apt::Key['logstash'],
61 }
62
63 package {'logstash':
64 ensure => $ensure ? {
65 /^(absent|purged)$/ => $ensure,
66 default => 'present',
67 },
68 require => Apt::Source['logstash'],
69 }
70
71 @package {'logstash-contrib':
72 before => Service['logstash'],
73 ensure => $ensure ? {
74 /^(absent|purged)$/ => $ensure,
75 default => 'present',
76 },
77 require => Package['logstash'],
78 }
79
80 @service {'logstash':
81 enable => $ensure ? {
82 /^(absent|purged)$/ => false,
83 default => true,
84 },
85 ensure => $ensure ? {
86 /^(running|started)$/ => 'running',
87 default => 'stopped',
88 },
89 hasrestart => true,
90 require => Package['logstash'],
91 }
92
93 file {'/usr/local/bin/logstash':
Felix Dahlke 2015/10/07 10:46:32 Would a symlink do? If not: AFAIK it's a sort of
mathias 2015/10/20 13:03:33 No, a symbolic link won't do. The /opt/logstash/bi
Felix Dahlke 2015/10/30 09:43:10 Acknowledged.
94 ensure => $ensure_file,
95 mode => 0755,
96 source => 'puppet:///modules/logstash/logstash.sh',
97 require => Package['logstash'],
98 }
99
100 if $contrib {
101 realize(Package['logstash-contrib'])
102 }
103
104 if $ensure !~ /^(absent|purged)$/ {
105 realize(Service['logstash'])
106 }
107
108 create_resources('logstash::pipeline', $pipelines)
109 }
OLDNEW

Powered by Google App Engine
This is Rietveld