Defined Type: elasticsearch::plugin

Defined in:
manifests/plugin.pp

Overview

Define: elasticsearch::plugin

This define allows you to install arbitrary Elasticsearch plugins either by using the default repositories or by specifying an URL

All default values are defined in the elasticsearch::params class.

Parameters

module_dir

Directory name where the module has been installed This is automatically generated based on the module name Specify a value here to override the auto generated value Value type is string Default value: None This variable is optional

ensure

Whether the plugin will be installed or removed. Set to ‘absent’ to ensure a plugin is not installed Value type is string Default value: present This variable is optional

url

Specify an URL where to download the plugin from. Value type is string Default value: None This variable is optional

source

Specify the source of the plugin. This will copy over the plugin to the node and use it for installation. Useful for offline installation Value type is string This variable is optional

proxy_host

Proxy host to use when installing the plugin Value type is string Default value: None This variable is optional

proxy_port

Proxy port to use when installing the plugin Value type is number Default value: None This variable is optional

proxy_username

Proxy auth username to use when installing the plugin Value type is string Default value: None This variable is optional

proxy_password

Proxy auth username to use when installing the plugin Value type is string Default value: None This variable is optional

instances

Specify all the instances related value type is string or array

Examples

# From official repository elasticsearch::pluginmodule_dir => ‘head’

# From custom url elasticsearch::plugin{ ‘elasticsearch-jetty’:

module_dir => 'elasticsearch-jetty',
url        => 'https://oss-es-plugins.s3.amazonaws.com/elasticsearch-jetty/elasticsearch-jetty-0.90.0.zip',

}

Authors

Parameters:

  • instances (Any) (defaults to: undef)
  • module_dir (Any) (defaults to: undef)
  • ensure (Any) (defaults to: 'present')
  • url (Any) (defaults to: undef)
  • source (Any) (defaults to: undef)
  • proxy_host (Any) (defaults to: undef)
  • proxy_port (Any) (defaults to: undef)
  • proxy_username (Any) (defaults to: undef)
  • proxy_password (Any) (defaults to: undef)


84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'manifests/plugin.pp', line 84

define elasticsearch::plugin(
  $instances      = undef,
  $module_dir     = undef,
  $ensure         = 'present',
  $url            = undef,
  $source         = undef,
  $proxy_host     = undef,
  $proxy_port     = undef,
  $proxy_username = undef,
  $proxy_password = undef,
) {

  include elasticsearch

  case $ensure {
    'installed', 'present': {
      if empty($instances) {
        fail('no $instances defined')
      }

      $_file_ensure = 'directory'
      $_file_before = []
    }
    'absent': {
      $_file_ensure = $ensure
      $_file_before = File[$elasticsearch::plugindir]
    }
    default: {
      fail("'${ensure}' is not a valid ensure parameter value")
    }
  }

  if ! empty($instances) and $elasticsearch::restart_plugin_change {
    Elasticsearch_plugin[$name] {
      notify +> Elasticsearch::Instance[$instances],
    }
  }

  # set proxy by override or parse and use proxy_url from
  # elasticsearch::proxy_url or use no proxy at all

  if ($proxy_host != undef and $proxy_port != undef) {
    if ($proxy_username != undef and $proxy_password != undef) {
      $_proxy_auth = "${proxy_username}:${proxy_password}@"
    } else {
      $_proxy_auth = undef
    }
    $_proxy = "http://${_proxy_auth}${proxy_host}:${proxy_port}"
  } elsif ($elasticsearch::proxy_url != undef) {
    $_proxy = $elasticsearch::proxy_url
  } else {
    $_proxy = undef
  }

  if ($source != undef) {

    $filename_array = split($source, '/')
    $basefilename = $filename_array[-1]

    $file_source = "${elasticsearch::package_dir}/${basefilename}"

    file { $file_source:
      ensure => 'file',
      source => $source,
      before => Elasticsearch_plugin[$name],
    }

  } else {
    $file_source = undef
  }

  if ($url != undef) {
    validate_string($url)
  }

  $_module_dir = es_plugin_name($module_dir, $name)

  elasticsearch_plugin { $name:
    ensure                     => $ensure,
    elasticsearch_package_name => $elasticsearch::package_name,
    source                     => $file_source,
    url                        => $url,
    proxy                      => $_proxy,
    plugin_dir                 => $::elasticsearch::plugindir,
    plugin_path                => $module_dir,
  } ->
  file { "${elasticsearch::plugindir}/${_module_dir}":
    ensure  => $_file_ensure,
    mode    => 'o+Xr',
    recurse => true,
    before  => $_file_before,
  }
}