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

Unified Diff: modules/elasticsearch/manifests/plugin.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 | « modules/elasticsearch/manifests/init.pp ('k') | modules/elasticsearch/templates/config.yml.erb » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: modules/elasticsearch/manifests/plugin.pp
diff --git a/modules/elasticsearch/manifests/plugin.pp b/modules/elasticsearch/manifests/plugin.pp
new file mode 100644
index 0000000000000000000000000000000000000000..fde9949bc2c944524c50319afb5534c3dfdf9c12
--- /dev/null
+++ b/modules/elasticsearch/manifests/plugin.pp
@@ -0,0 +1,69 @@
+# == Type: elasticsearch::plugin
+#
+# Manage Elasticsearch plugin installations.
+#
+# === Parameters:
+#
+# [*ensure*]
+# Either 'present'/'installed' or 'absent'/'purged'.
+#
+# [*replace*]
+# Whether to replace an existing plugin during installation.
+#
+# [*url*]
+# Where to download a plugin from during installation, if not publicly
+# available at one of the default URLs.
+#
+# [*version*]
+# An explicit version to install.
+#
+# === Examples:
+#
+# elasticsearch::plugin {'license':
+# url => $elasticsearch_license_plugin_url,
+# }
+#
+# elasticsearch::plugin {'shield':
+# require => Elasticsearch::Plugin['license'],
+# }
+#
+define elasticsearch::plugin (
+ $ensure = 'present',
+ $replace = false,
+ $url = undef,
+ $version = 'latest',
+) {
+
+ $plugin = "${elasticsearch::directory}/bin/plugin"
+
+ Exec {
+ cwd => $elasticsearch::directory,
+ logoutput => true,
+ notify => Service['elasticsearch'],
+ require => Package['elasticsearch'],
+ }
+
+ @exec {"elasticsearch::plugin#install-$name":
+ command => shellquote($url ? {
+ undef => [$plugin, '--install', "elasticsearch/$name/$version"],
+ default => [$plugin, '--install', $name, '--url', $url, '--verbose'],
+ }),
+ creates => "${elasticsearch::directory}/plugins/$name",
+ }
+
+ @exec {"elasticsearch::plugin#remove-$name":
+ command => shellquote($plugin, '--remove', $name),
+ onlyif => shellquote('/usr/bin/test', '-e', "plugins/$name"),
+ }
+
+ if $ensure =~ /^(absent|purged)$/ {
+ realize(Exec["elasticsearch::plugin#remove-$name"])
+ }
+ elsif $replace == true {
+ Exec <|title == "elasticsearch::plugin#remove-$name"|> ->
+ Exec <|title == "elasticsearch::plugin#install-$name"|>
+ }
+ else {
+ realize(Exec["elasticsearch::plugin#install-$name"])
+ }
+}
« no previous file with comments | « modules/elasticsearch/manifests/init.pp ('k') | modules/elasticsearch/templates/config.yml.erb » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld