Index: modules/elasticsearch/manifests/init.pp |
diff --git a/modules/elasticsearch/manifests/init.pp b/modules/elasticsearch/manifests/init.pp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..9acee91a155ef8de0a4ee1e7f34ca0f0f6997cbd |
--- /dev/null |
+++ b/modules/elasticsearch/manifests/init.pp |
@@ -0,0 +1,97 @@ |
+# == Class: elasticsearch |
+# |
+# Manage Elasticsearch (https://www.elastic.co/products/elasticsearch) |
+# installations via APT. |
+# |
+# === Parameters: |
+# |
+# [*directory*] |
+# The root directory of the Elasticsearch installation. |
+# |
+# [*ensure*] |
+# Either 'present'/'stopped', 'running'/'started', or 'absent'/'purged'. |
+# Note that Service['elasticsearch'] is only realized implicitly when |
+# $ensure is neither 'absent' nor 'purged'. |
+# |
+# [*java_packages*] |
+# A list of package names required to ensure a JDK for running the |
+# Elasticsearch service being present. |
+# |
+# [*plugins*] |
+# A hash of elasticsearch::plugin setups to ensure implicitly. |
+# |
+# [*settings*] |
+# A hash of options that translate directly into entires in the global |
+# Elasticsearch configuration file. |
+# |
+# [*version*] |
+# The http://packages.elasticsearch.org/elasticsearch/%s/debian $version. |
+# |
+# === Examples: |
+# |
+# class {'elasticsearch': |
+# } |
+# |
+class elasticsearch ( |
+ $directory = '/usr/share/elasticsearch', |
+ $ensure = 'running', |
+ $java_packages = ['openjdk-7-jre'], |
+ $plugins = {}, |
+ $settings = {}, |
+ $version = '1.6', |
+) { |
+ |
+ $ensure_file = $ensure ? { |
+ /^(absent|purged)$/ => 'absent', |
+ default => 'present', |
+ } |
+ |
+ ensure_packages($java_packages) |
+ |
+ apt::key {'elasticsearch': |
+ ensure => $ensure_file, |
+ key => 'D88E42B4', |
+ key_content => template('elasticsearch/elasticsearch-gpg-key.erb'), |
+ } |
+ |
+ apt::source {'elasticsearch': |
+ ensure => $ensure_file, |
+ include_src => false, |
+ location => "http://packages.elasticsearch.org/elasticsearch/$version/debian", |
+ release => 'stable', |
+ require => Apt::Key['elasticsearch'], |
+ } |
+ |
+ package {'elasticsearch': |
+ ensure => $ensure_file, |
+ require => Apt::Source['elasticsearch'], |
+ } |
+ |
+ @service {'elasticsearch': |
+ enable => $ensure ? { |
+ /^(absent|purged)$/ => false, |
+ default => true, |
+ }, |
+ ensure => $ensure ? { |
+ /^(running|started)$/ => 'running', |
+ default => 'stopped', |
+ }, |
+ hasrestart => true, |
+ require => Package['elasticsearch'], |
+ subscribe => Package[$java_packages], |
+ } |
+ |
+ file {'elasticsearch.yml': |
+ content => template('elasticsearch/config.yml.erb'), |
+ ensure => $ensure_file, |
+ notify => Service['elasticsearch'], |
+ path => '/etc/elasticsearch/elasticsearch.yml', |
+ require => Package['elasticsearch'], |
+ } |
+ |
+ if $ensure !~ /^(absent|purged)$/ { |
+ realize(Service['elasticsearch']) |
+ } |
+ |
+ create_resources('elasticsearch::plugin', $plugins) |
+} |