28
|
1 |
# == Define: elasticsearch::script |
|
2 |
# |
|
3 |
# This define allows you to insert, update or delete scripts that are used within Elasticsearch |
|
4 |
# |
|
5 |
# === Parameters |
|
6 |
# |
|
7 |
# [*ensure*] |
|
8 |
# String. Controls if the managed resources shall be <tt>present</tt> or |
|
9 |
# <tt>absent</tt>. If set to <tt>absent</tt>: |
|
10 |
# * The managed software packages are being uninstalled. |
|
11 |
# * Any traces of the packages will be purged as good as possible. This may |
|
12 |
# include existing configuration files. The exact behavior is provider |
|
13 |
# dependent. Q.v.: |
|
14 |
# * Puppet type reference: {package, "purgeable"}[http://j.mp/xbxmNP] |
|
15 |
# * {Puppet's package provider source code}[http://j.mp/wtVCaL] |
|
16 |
# * System modifications (if any) will be reverted as good as possible |
|
17 |
# (e.g. removal of created users, services, changed log settings, ...). |
|
18 |
# * This is thus destructive and should be used with care. |
|
19 |
# Defaults to <tt>present</tt>. |
|
20 |
# |
|
21 |
# [*source*] |
|
22 |
# Puppet source of the script |
|
23 |
# Value type is string |
|
24 |
# Default value: undef |
|
25 |
# This variable is mandatory |
|
26 |
# |
|
27 |
# === Authors |
|
28 |
# |
|
29 |
# * Richard Pijnenburg <mailto:richard.pijnenburg@elasticsearch.com> |
|
30 |
# |
|
31 |
define elasticsearch::script( |
|
32 |
$source, |
|
33 |
$ensure = 'present', |
|
34 |
) { |
|
35 |
|
|
36 |
require elasticsearch |
|
37 |
|
|
38 |
# ensure |
|
39 |
if ! ($ensure in [ 'present', 'absent' ]) { |
|
40 |
fail("\"${ensure}\" is not a valid ensure parameter value") |
|
41 |
} |
|
42 |
|
|
43 |
validate_re($source, '^(puppet|file)://') |
|
44 |
|
|
45 |
$filenameArray = split($source, '/') |
|
46 |
$basefilename = $filenameArray[-1] |
|
47 |
|
|
48 |
file { "${elasticsearch::params::homedir}/scripts/${basefilename}": |
|
49 |
ensure => $ensure, |
|
50 |
source => $source, |
|
51 |
owner => $elasticsearch::elasticsearch_user, |
|
52 |
group => $elasticsearch::elasticsearch_group, |
|
53 |
mode => '0644', |
|
54 |
} |
|
55 |
} |