upgrade to elasticsearch/elasticsearch 0.9.6
[mirror/dsa-puppet.git] / 3rdparty / modules / elasticsearch / manifests / plugin.pp
index f49a6bd..9cd0448 100644 (file)
@@ -64,7 +64,7 @@ define elasticsearch::plugin(
     $module_dir,
     $instances,
     $ensure      = 'present',
-    $url         = '',
+    $url         = undef,
     $proxy_host  = undef,
     $proxy_port  = undef,
 ) {
@@ -76,7 +76,8 @@ define elasticsearch::plugin(
     cwd       => '/',
     user      => $elasticsearch::elasticsearch_user,
     tries     => 6,
-    try_sleep => 10
+    try_sleep => 10,
+    timeout   => 600,
   }
 
   $notify_service = $elasticsearch::restart_on_change ? {
@@ -93,7 +94,7 @@ define elasticsearch::plugin(
   if ($proxy_host != undef and $proxy_port != undef) {
     $proxy = " -DproxyPort=${proxy_port} -DproxyHost=${proxy_host}"
   } else {
-    $proxy = ''
+    $proxy = '' # lint:ignore:empty_string_assignment
   }
 
   if ($url != '') {
@@ -107,12 +108,23 @@ define elasticsearch::plugin(
 
   case $ensure {
     'installed', 'present': {
+      $name_file_path = "${elasticsearch::plugindir}/${module_dir}/.name"
+      exec {"purge_plugin_${module_dir}_old":
+        command => "${elasticsearch::plugintool} --remove ${module_dir}",
+        onlyif  => "test -e ${elasticsearch::plugindir}/${module_dir} && test \"$(cat ${name_file_path})\" != '${name}'",
+        before  => Exec["install_plugin_${name}"],
+      }
       exec {"install_plugin_${name}":
         command => $install_cmd,
         creates => "${elasticsearch::plugindir}/${module_dir}",
         returns => $exec_rets,
         notify  => $notify_service,
-        require => File[$elasticsearch::plugindir]
+        require => File[$elasticsearch::plugindir],
+      }
+      file {$name_file_path:
+        ensure  => file,
+        content => $name,
+        require => Exec["install_plugin_${name}"],
       }
     }
     default: {