Index: modules/logstash/manifests/init.pp |
diff --git a/modules/logstash/manifests/init.pp b/modules/logstash/manifests/init.pp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..59cade6dcc269ed26240791fd3b5f3cc011cdc43 |
--- /dev/null |
+++ b/modules/logstash/manifests/init.pp |
@@ -0,0 +1,109 @@ |
+# == Class: logstash |
+# |
+# Manage Logstash (https://logstash.net/) installations via APT. |
+# |
+# Please refer to the online documentation at Elastic for more information |
+# on the logstash software, it's usage and configuration options: |
+# |
+# https://www.elastic.co/guide/en/logstash/current/index.html |
+# |
+# === Parameters: |
+# |
+# [*contrib*] |
+# Whether to realize Package['logstash-contrib']. |
+# |
+# [*ensure*] |
+# Either 'present'/'stopped', 'running'/'started', or 'absent'/'purged'. |
+# Note that Service['logstash'] is only realized implicitly when $ensure |
+# is neither 'absent' nor 'purged'. |
+# |
+# [*pipelines*] |
+# A hash to setup logstash::pipeline {$name: $parameter} resources. |
+# |
+# [*version*] |
+# The http://packages.elasticsearch.org/logstash/%s/debian $version. |
+# |
+# === Examples: |
+# |
+# class {'logstash': |
+# contrib => true, |
+# pipelines => { |
+# 'example' => { |
+# # see type logstash::pipeline for a parameter reference |
+# }, |
+# }, |
+# } |
+# |
+class logstash ( |
+ $contrib = false, |
+ $ensure = 'running', |
+ $pipelines = {}, |
+ $version = '1.4', |
+) { |
+ |
+ $ensure_file = $ensure ? { |
+ /^(absent|purged)$/ => 'absent', |
+ default => 'present', |
+ } |
+ |
+ apt::key {'logstash': |
+ ensure => $ensure_file, |
+ key => 'D88E42B4', |
+ key_content => template('logstash/elastic-logstash-gpg-key.erb'), |
+ } |
+ |
+ apt::source {'logstash': |
+ ensure => $ensure_file, |
+ include_src => false, |
+ 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.
|
+ release => 'stable', |
+ require => Apt::Key['logstash'], |
+ } |
+ |
+ package {'logstash': |
+ ensure => $ensure ? { |
+ /^(absent|purged)$/ => $ensure, |
+ default => 'present', |
+ }, |
+ require => Apt::Source['logstash'], |
+ } |
+ |
+ @package {'logstash-contrib': |
+ before => Service['logstash'], |
+ ensure => $ensure ? { |
+ /^(absent|purged)$/ => $ensure, |
+ default => 'present', |
+ }, |
+ require => Package['logstash'], |
+ } |
+ |
+ @service {'logstash': |
+ enable => $ensure ? { |
+ /^(absent|purged)$/ => false, |
+ default => true, |
+ }, |
+ ensure => $ensure ? { |
+ /^(running|started)$/ => 'running', |
+ default => 'stopped', |
+ }, |
+ hasrestart => true, |
+ require => Package['logstash'], |
+ } |
+ |
+ 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.
|
+ ensure => $ensure_file, |
+ mode => 0755, |
+ source => 'puppet:///modules/logstash/logstash.sh', |
+ require => Package['logstash'], |
+ } |
+ |
+ if $contrib { |
+ realize(Package['logstash-contrib']) |
+ } |
+ |
+ if $ensure !~ /^(absent|purged)$/ { |
+ realize(Service['logstash']) |
+ } |
+ |
+ create_resources('logstash::pipeline', $pipelines) |
+} |