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
All default values are defined in the elasticsearch::params class.
52 53 54 55 56 57 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 52
define elasticsearch::plugin (
$ensure = 'present',
$instances = undef,
$module_dir = undef,
$proxy_host = undef,
$proxy_password = undef,
$proxy_port = undef,
$proxy_username = undef,
$source = undef,
$url = undef,
) {
include elasticsearch
case $ensure {
'installed', 'present': {
if empty($instances) and $elasticsearch::restart_plugin_change {
fail('no $instances defined, even tho `restart_plugin_change` is set!')
}
$_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,
}
}
|