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

Unified Diff: modules/elasticsearch/manifests/init.pp

Issue 29327597: Issue 2864 - Introduce class elasticsearch (Closed)
Patch Set: Created Sept. 14, 2015, 7:26 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « hiera/roles/elasticsearch.yaml ('k') | modules/elasticsearch/manifests/plugin.pp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
+}
« no previous file with comments | « hiera/roles/elasticsearch.yaml ('k') | modules/elasticsearch/manifests/plugin.pp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld