OLD | NEW |
(Empty) | |
| 1 # == Type: elasticsearch::plugin |
| 2 # |
| 3 # Manage Elasticsearch plugin installations. |
| 4 # |
| 5 # === Parameters: |
| 6 # |
| 7 # [*ensure*] |
| 8 # Either 'present'/'installed' or 'absent'/'purged'. |
| 9 # |
| 10 # [*replace*] |
| 11 # Whether to replace an existing plugin during installation. |
| 12 # |
| 13 # [*url*] |
| 14 # Where to download a plugin from during installation, if not publicly |
| 15 # available at one of the default URLs. |
| 16 # |
| 17 # [*version*] |
| 18 # An explicit version to install. |
| 19 # |
| 20 # === Examples: |
| 21 # |
| 22 # elasticsearch::plugin {'license': |
| 23 # url => $elasticsearch_license_plugin_url, |
| 24 # } |
| 25 # |
| 26 # elasticsearch::plugin {'shield': |
| 27 # require => Elasticsearch::Plugin['license'], |
| 28 # } |
| 29 # |
| 30 define elasticsearch::plugin ( |
| 31 $ensure = 'present', |
| 32 $replace = false, |
| 33 $url = undef, |
| 34 $version = 'latest', |
| 35 ) { |
| 36 |
| 37 $plugin = "${elasticsearch::directory}/bin/plugin" |
| 38 |
| 39 Exec { |
| 40 cwd => $elasticsearch::directory, |
| 41 logoutput => true, |
| 42 notify => Service['elasticsearch'], |
| 43 require => Package['elasticsearch'], |
| 44 } |
| 45 |
| 46 @exec {"elasticsearch::plugin#install-$name": |
| 47 command => shellquote($url ? { |
| 48 undef => [$plugin, '--install', "elasticsearch/$name/$version"], |
| 49 default => [$plugin, '--install', $name, '--url', $url, '--verbose'], |
| 50 }), |
| 51 creates => "${elasticsearch::directory}/plugins/$name", |
| 52 } |
| 53 |
| 54 @exec {"elasticsearch::plugin#remove-$name": |
| 55 command => shellquote($plugin, '--remove', $name), |
| 56 onlyif => shellquote('/usr/bin/test', '-e', "plugins/$name"), |
| 57 } |
| 58 |
| 59 if $ensure =~ /^(absent|purged)$/ { |
| 60 realize(Exec["elasticsearch::plugin#remove-$name"]) |
| 61 } |
| 62 elsif $replace == true { |
| 63 Exec <|title == "elasticsearch::plugin#remove-$name"|> -> |
| 64 Exec <|title == "elasticsearch::plugin#install-$name"|> |
| 65 } |
| 66 else { |
| 67 realize(Exec["elasticsearch::plugin#install-$name"]) |
| 68 } |
| 69 } |
OLD | NEW |