Defined Type: elasticsearch::plugin

Defined in:
manifests/plugin.pp

Overview

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

Examples:

install from official repository

elasticsearch::plugin {'mobz/elasticsearch-head': module_dir => 'head'}

installation using a 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',
}

Parameters:

  • ensure (Enum['absent', 'present']) (defaults to: 'present')

    Whether the plugin will be installed or removed. Set to ‘absent’ to ensure a plugin is not installed

  • configdir (Stdlib::Absolutepath) (defaults to: $elasticsearch::configdir)

    Path to the elasticsearch configuration directory (ES_PATH_CONF) to which the plugin should be installed.

  • java_opts (Array[String]) (defaults to: [])

    Array of Java options to be passed to ‘ES_JAVA_OPTS`

  • java_home (Optional[Stdlib::Absolutepath]) (defaults to: undef)

    Path to JAVA_HOME, if Java is installed in a non-standard location.

  • module_dir (Optional[String]) (defaults to: undef)

    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

  • proxy_host (Optional[String]) (defaults to: undef)

    Proxy host to use when installing the plugin

  • proxy_password (Optional[String]) (defaults to: undef)

    Proxy auth password to use when installing the plugin

  • proxy_port (Optional[Integer[0, 65535]]) (defaults to: undef)

    Proxy port to use when installing the plugin

  • proxy_username (Optional[String]) (defaults to: undef)

    Proxy auth username to use when installing the plugin

  • source (Optional[String]) (defaults to: undef)

    Specify the source of the plugin. This will copy over the plugin to the node and use it for installation. Useful for offline installation

  • url (Optional[Stdlib::HTTPUrl]) (defaults to: undef)

    Specify an URL where to download the plugin from.

Author:

  • Richard Pijnenburg <richard.pijnenburg@elasticsearch.com>

  • Matteo Sessa <matteo.sessa@catchoftheday.com.au>

  • Dennis Konert <dkonert@gmail.com>

  • Tyler Langlois <tyler.langlois@elastic.co>

  • Gavin Williams <gavin.williams@elastic.co>



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
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
# File 'manifests/plugin.pp', line 58

define elasticsearch::plugin (
  Enum['absent', 'present']      $ensure         = 'present',
  Stdlib::Absolutepath           $configdir      = $elasticsearch::configdir,
  Array[String]                  $java_opts      = [],
  Optional[Stdlib::Absolutepath] $java_home      = undef,
  Optional[String]               $module_dir     = undef,
  Optional[String]               $proxy_host     = undef,
  Optional[String]               $proxy_password = undef,
  Optional[Integer[0, 65535]]    $proxy_port     = undef,
  Optional[String]               $proxy_username = undef,
  Optional[String]               $source         = undef,
  Optional[Stdlib::HTTPUrl]      $url            = undef,
) {
  include elasticsearch

  case $ensure {
    'present': {
      $_file_ensure = 'directory'
      $_file_before = []
    }
    'absent': {
      $_file_ensure = $ensure
      $_file_before = File[$elasticsearch::real_plugindir]
    }
    default: {
    }
  }

  # 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
  }

  $_module_dir = es_plugin_name($module_dir, $name)

  elasticsearch_plugin { $name:
    ensure                     => $ensure,
    configdir                  => $configdir,
    elasticsearch_package_name => 'elasticsearch',
    java_opts                  => $java_opts,
    java_home                  => $java_home,
    source                     => $file_source,
    url                        => $url,
    proxy                      => $_proxy,
    plugin_dir                 => $elasticsearch::real_plugindir,
    plugin_path                => $module_dir,
    before                     => Service[$elasticsearch::service_name],
  }
  -> file { "${elasticsearch::real_plugindir}/${_module_dir}":
    ensure  => $_file_ensure,
    mode    => 'o+Xr',
    recurse => true,
    before  => $_file_before,
  }

  if $elasticsearch::restart_plugin_change {
    Elasticsearch_plugin[$name] {
      notify +> Service[$elasticsearch::service_name],
    }
  }
}