author | ymh <ymh.work@gmail.com> |
Wed, 09 Nov 2016 15:05:41 +0100 | |
changeset 406 | cf0f23803a53 |
parent 28 | b0b56e0f8c7f |
permissions | -rwxr-xr-x |
28 | 1 |
# == Class: elasticsearch::service |
2 |
# |
|
3 |
# This class exists to coordinate all service management related actions, |
|
4 |
# functionality and logical units in a central place. |
|
5 |
# |
|
6 |
# <b>Note:</b> "service" is the Puppet term and type for background processes |
|
7 |
# in general and is used in a platform-independent way. E.g. "service" means |
|
8 |
# "daemon" in relation to Unix-like systems. |
|
9 |
# |
|
10 |
# |
|
11 |
# === Parameters |
|
12 |
# |
|
13 |
# [*ensure*] |
|
14 |
# String. Controls if the managed resources shall be <tt>present</tt> or |
|
15 |
# <tt>absent</tt>. If set to <tt>absent</tt>: |
|
16 |
# * The managed software packages are being uninstalled. |
|
17 |
# * Any traces of the packages will be purged as good as possible. This may |
|
18 |
# include existing configuration files. The exact behavior is provider |
|
19 |
# dependent. Q.v.: |
|
20 |
# * Puppet type reference: {package, "purgeable"}[http://j.mp/xbxmNP] |
|
21 |
# * {Puppet's package provider source code}[http://j.mp/wtVCaL] |
|
22 |
# * System modifications (if any) will be reverted as good as possible |
|
23 |
# (e.g. removal of created users, services, changed log settings, ...). |
|
24 |
# * This is thus destructive and should be used with care. |
|
25 |
# Defaults to <tt>present</tt>. |
|
26 |
# |
|
27 |
# [*status*] |
|
28 |
# String to define the status of the service. Possible values: |
|
29 |
# * <tt>enabled</tt>: Service is running and will be started at boot time. |
|
30 |
# * <tt>disabled</tt>: Service is stopped and will not be started at boot |
|
31 |
# time. |
|
32 |
# * <tt>running</tt>: Service is running but will not be started at boot time. |
|
33 |
# You can use this to start a service on the first Puppet run instead of |
|
34 |
# the system startup. |
|
35 |
# * <tt>unmanaged</tt>: Service will not be started at boot time and Puppet |
|
36 |
# does not care whether the service is running or not. For example, this may |
|
37 |
# be useful if a cluster management software is used to decide when to start |
|
38 |
# the service plus assuring it is running on the desired node. |
|
39 |
# Defaults to <tt>enabled</tt>. The singular form ("service") is used for the |
|
40 |
# sake of convenience. Of course, the defined status affects all services if |
|
41 |
# more than one is managed (see <tt>service.pp</tt> to check if this is the |
|
42 |
# case). |
|
43 |
# |
|
44 |
# [*init_defaults*] |
|
45 |
# Defaults file content in hash representation |
|
46 |
# |
|
47 |
# [*init_defaults_file*] |
|
48 |
# Defaults file as puppet resource |
|
49 |
# |
|
50 |
# [*init_template*] |
|
51 |
# Service file as a template |
|
52 |
# |
|
406
cf0f23803a53
upgrade elasticsearch to 5.0, upgrade ember
ymh <ymh.work@gmail.com>
parents:
28
diff
changeset
|
53 |
# [*service_flags*] |
cf0f23803a53
upgrade elasticsearch to 5.0, upgrade ember
ymh <ymh.work@gmail.com>
parents:
28
diff
changeset
|
54 |
# Service flags, used on OpenBSD for service configuration |
cf0f23803a53
upgrade elasticsearch to 5.0, upgrade ember
ymh <ymh.work@gmail.com>
parents:
28
diff
changeset
|
55 |
# |
28 | 56 |
# === Authors |
57 |
# |
|
58 |
# * Richard Pijnenburg <mailto:richard.pijnenburg@elasticsearch.com> |
|
59 |
# |
|
60 |
define elasticsearch::service( |
|
61 |
$ensure = $elasticsearch::ensure, |
|
62 |
$status = $elasticsearch::status, |
|
63 |
$init_defaults_file = undef, |
|
64 |
$init_defaults = undef, |
|
65 |
$init_template = undef, |
|
406
cf0f23803a53
upgrade elasticsearch to 5.0, upgrade ember
ymh <ymh.work@gmail.com>
parents:
28
diff
changeset
|
66 |
$service_flags = undef, |
28 | 67 |
) { |
68 |
||
69 |
case $elasticsearch::real_service_provider { |
|
70 |
||
71 |
'init': { |
|
72 |
elasticsearch::service::init { $name: |
|
73 |
ensure => $ensure, |
|
74 |
status => $status, |
|
75 |
init_defaults_file => $init_defaults_file, |
|
76 |
init_defaults => $init_defaults, |
|
77 |
init_template => $init_template, |
|
78 |
} |
|
79 |
} |
|
406
cf0f23803a53
upgrade elasticsearch to 5.0, upgrade ember
ymh <ymh.work@gmail.com>
parents:
28
diff
changeset
|
80 |
'openbsd': { |
cf0f23803a53
upgrade elasticsearch to 5.0, upgrade ember
ymh <ymh.work@gmail.com>
parents:
28
diff
changeset
|
81 |
elasticsearch::service::openbsd { $name: |
cf0f23803a53
upgrade elasticsearch to 5.0, upgrade ember
ymh <ymh.work@gmail.com>
parents:
28
diff
changeset
|
82 |
ensure => $ensure, |
cf0f23803a53
upgrade elasticsearch to 5.0, upgrade ember
ymh <ymh.work@gmail.com>
parents:
28
diff
changeset
|
83 |
status => $status, |
cf0f23803a53
upgrade elasticsearch to 5.0, upgrade ember
ymh <ymh.work@gmail.com>
parents:
28
diff
changeset
|
84 |
init_template => $init_template, |
cf0f23803a53
upgrade elasticsearch to 5.0, upgrade ember
ymh <ymh.work@gmail.com>
parents:
28
diff
changeset
|
85 |
service_flags => $service_flags, |
cf0f23803a53
upgrade elasticsearch to 5.0, upgrade ember
ymh <ymh.work@gmail.com>
parents:
28
diff
changeset
|
86 |
} |
cf0f23803a53
upgrade elasticsearch to 5.0, upgrade ember
ymh <ymh.work@gmail.com>
parents:
28
diff
changeset
|
87 |
} |
28 | 88 |
'systemd': { |
89 |
elasticsearch::service::systemd { $name: |
|
90 |
ensure => $ensure, |
|
91 |
status => $status, |
|
92 |
init_defaults_file => $init_defaults_file, |
|
93 |
init_defaults => $init_defaults, |
|
94 |
init_template => $init_template, |
|
95 |
} |
|
96 |
} |
|
406
cf0f23803a53
upgrade elasticsearch to 5.0, upgrade ember
ymh <ymh.work@gmail.com>
parents:
28
diff
changeset
|
97 |
'openrc': { |
cf0f23803a53
upgrade elasticsearch to 5.0, upgrade ember
ymh <ymh.work@gmail.com>
parents:
28
diff
changeset
|
98 |
elasticsearch::service::openrc { $name: |
cf0f23803a53
upgrade elasticsearch to 5.0, upgrade ember
ymh <ymh.work@gmail.com>
parents:
28
diff
changeset
|
99 |
ensure => $ensure, |
cf0f23803a53
upgrade elasticsearch to 5.0, upgrade ember
ymh <ymh.work@gmail.com>
parents:
28
diff
changeset
|
100 |
status => $status, |
cf0f23803a53
upgrade elasticsearch to 5.0, upgrade ember
ymh <ymh.work@gmail.com>
parents:
28
diff
changeset
|
101 |
init_defaults_file => $init_defaults_file, |
cf0f23803a53
upgrade elasticsearch to 5.0, upgrade ember
ymh <ymh.work@gmail.com>
parents:
28
diff
changeset
|
102 |
init_defaults => $init_defaults, |
cf0f23803a53
upgrade elasticsearch to 5.0, upgrade ember
ymh <ymh.work@gmail.com>
parents:
28
diff
changeset
|
103 |
init_template => $init_template, |
cf0f23803a53
upgrade elasticsearch to 5.0, upgrade ember
ymh <ymh.work@gmail.com>
parents:
28
diff
changeset
|
104 |
} |
cf0f23803a53
upgrade elasticsearch to 5.0, upgrade ember
ymh <ymh.work@gmail.com>
parents:
28
diff
changeset
|
105 |
} |
28 | 106 |
default: { |
107 |
fail("Unknown service provider ${elasticsearch::real_service_provider}") |
|
108 |
} |
|
109 |
||
110 |
} |
|
111 |
||
112 |
} |