1 # == Define: elasticsearch::plugin
3 # This define allows you to install arbitrary Elasticsearch plugins
4 # either by using the default repositories or by specifying an URL
6 # All default values are defined in the elasticsearch::params class.
12 # Directory name where the module will be installed
13 # Value type is string
15 # This variable is required
18 # Whether the plugin will be installed or removed.
19 # Set to 'absent' to ensure a plugin is not installed
20 # Value type is string
21 # Default value: present
22 # This variable is optional
25 # Specify an URL where to download the plugin from.
26 # Value type is string
28 # This variable is optional
31 # Proxy host to use when installing the plugin
32 # Value type is string
34 # This variable is optional
37 # Proxy port to use when installing the plugin
38 # Value type is number
40 # This variable is optional
43 # Specify all the instances related
44 # value type is string or array
48 # # From official repository
49 # elasticsearch::plugin{'mobz/elasticsearch-head': module_dir => 'head'}
52 # elasticsearch::plugin{ 'elasticsearch-jetty':
53 # module_dir => 'elasticsearch-jetty',
54 # url => 'https://oss-es-plugins.s3.amazonaws.com/elasticsearch-jetty/elasticsearch-jetty-0.90.0.zip',
59 # * Matteo Sessa <mailto:matteo.sessa@catchoftheday.com.au>
60 # * Dennis Konert <mailto:dkonert@gmail.com>
61 # * Richard Pijnenburg <mailto:richard.pijnenburg@elasticsearch.com>
63 define elasticsearch::plugin(
75 path => [ '/bin', '/usr/bin', '/usr/local/bin' ],
77 user => $elasticsearch::elasticsearch_user,
83 $notify_service = $elasticsearch::restart_on_change ? {
85 default => Elasticsearch::Service[$instances],
88 if ($module_dir != '') {
89 validate_string($module_dir)
91 fail("module_dir undefined for plugin ${name}")
94 if ($proxy_host != undef and $proxy_port != undef) {
95 $proxy = " -DproxyPort=${proxy_port} -DproxyHost=${proxy_host}"
97 $proxy = '' # lint:ignore:empty_string_assignment
101 validate_string($url)
102 $install_cmd = "${elasticsearch::plugintool}${proxy} -install ${name} -url ${url}"
105 $install_cmd = "${elasticsearch::plugintool}${proxy} -install ${name}"
110 'installed', 'present': {
111 $name_file_path = "${elasticsearch::plugindir}/${module_dir}/.name"
112 exec {"purge_plugin_${module_dir}_old":
113 command => "${elasticsearch::plugintool} --remove ${module_dir}",
114 onlyif => "test -e ${elasticsearch::plugindir}/${module_dir} && test \"$(cat ${name_file_path})\" != '${name}'",
115 before => Exec["install_plugin_${name}"],
117 exec {"install_plugin_${name}":
118 command => $install_cmd,
119 creates => "${elasticsearch::plugindir}/${module_dir}",
120 returns => $exec_rets,
121 notify => $notify_service,
122 require => File[$elasticsearch::plugindir],
124 file {$name_file_path:
127 require => Exec["install_plugin_${name}"],
131 exec {"remove_plugin_${name}":
132 command => "${elasticsearch::plugintool} --remove ${module_dir}",
133 onlyif => "test -d ${elasticsearch::plugindir}/${module_dir}",
134 notify => $notify_service,