|
1 |
| -# == Class: logstash |
2 |
| -# |
3 |
| -# This class is able to install or remove logstash on a node. |
4 |
| -# It manages the status of the related service. |
5 |
| -# |
6 |
| -# |
7 |
| -# === Parameters |
8 |
| -# |
9 |
| -# [*ensure*] |
10 |
| -# String. Controls if the managed resources shall be <tt>present</tt> or |
11 |
| -# <tt>absent</tt>. If set to <tt>absent</tt>: |
12 |
| -# * The managed software packages are being uninstalled. |
13 |
| -# * Any traces of the packages will be purged as good as possible. This may |
14 |
| -# include existing configuration files. The exact behavior is provider |
15 |
| -# dependent. Q.v.: |
16 |
| -# * Puppet type reference: {package, "purgeable"}[http://j.mp/xbxmNP] |
17 |
| -# * {Puppet's package provider source code}[http://j.mp/wtVCaL] |
18 |
| -# * System modifications (if any) will be reverted as good as possible |
19 |
| -# (e.g. removal of created users, services, changed log settings, ...). |
20 |
| -# * This is thus destructive and should be used with care. |
21 |
| -# Defaults to <tt>present</tt>. |
22 |
| -# |
23 |
| -# [*autoupgrade*] |
24 |
| -# Boolean. If set to <tt>true</tt>, any managed package gets upgraded |
25 |
| -# on each Puppet run when the package provider is able to find a newer |
26 |
| -# version than the present one. The exact behavior is provider dependent. |
27 |
| -# Q.v.: |
28 |
| -# * Puppet type reference: {package, "upgradeable"}[http://j.mp/xbxmNP] |
29 |
| -# * {Puppet's package provider source code}[http://j.mp/wtVCaL] |
30 |
| -# Defaults to <tt>false</tt>. |
31 |
| -# |
32 |
| -# [*status*] |
33 |
| -# String to define the status of the service. Possible values: |
34 |
| -# * <tt>enabled</tt>: Service is running and will be started at boot time. |
35 |
| -# * <tt>disabled</tt>: Service is stopped and will not be started at boot |
36 |
| -# time. |
37 |
| -# * <tt>running</tt>: Service is running but will not be started at boot time. |
38 |
| -# You can use this to start a service on the first Puppet run instead of |
39 |
| -# the system startup. |
40 |
| -# * <tt>unmanaged</tt>: Service will not be started at boot time and Puppet |
41 |
| -# does not care whether the service is running or not. For example, this may |
42 |
| -# be useful if a cluster management software is used to decide when to start |
43 |
| -# the service plus assuring it is running on the desired node. |
44 |
| -# Defaults to <tt>enabled</tt>. The singular form ("service") is used for the |
45 |
| -# sake of convenience. Of course, the defined status affects all services if |
46 |
| -# more than one is managed (see <tt>service.pp</tt> to check if this is the |
47 |
| -# case). |
48 |
| -# |
49 |
| -# [*version*] |
50 |
| -# String to set the specific core package version you want to install. |
51 |
| -# Defaults to <tt>false</tt>. |
52 |
| -# |
53 |
| -# [*restart_on_change*] |
54 |
| -# Boolean that determines if the application should be automatically restarted |
55 |
| -# whenever the configuration changes. Disabling automatic restarts on config |
56 |
| -# changes may be desired in an environment where you need to ensure restarts |
57 |
| -# occur in a controlled/rolling manner rather than during a Puppet run. |
58 |
| -# |
59 |
| -# Defaults to <tt>true</tt>, which will restart the application on any config |
60 |
| -# change. Setting to <tt>false</tt> disables the automatic restart. |
61 |
| -# |
62 |
| -# The default values for the parameters are set in logstash::params. Have |
63 |
| -# a look at the corresponding <tt>params.pp</tt> manifest file if you need more |
64 |
| -# technical information about them. |
65 |
| -# |
66 |
| -# [*package_url*] |
67 |
| -# Url to the package to download. |
68 |
| -# This can be a http,https or ftp resource for remote packages |
69 |
| -# puppet:// resource or file:/ for local packages |
70 |
| -# |
71 |
| -# [*package_name*] |
72 |
| -# Logstash packagename |
73 |
| -# |
74 |
| -# [*download_timeout*] |
75 |
| -# For http,https and ftp downloads you can set howlong the exec resource may take. |
76 |
| -# Defaults to: 600 seconds |
77 |
| -# |
78 |
| -# [*logstash_user*] |
79 |
| -# The user Logstash should run as. This also sets the file rights. |
80 |
| -# |
81 |
| -# [*logstash_group*] |
82 |
| -# The group logstash should run as. This also sets the file rights |
83 |
| -# |
84 |
| -# [*purge_configdir*] |
85 |
| -# Purge the config directory for any unmanaged files |
86 |
| -# |
87 |
| -# [*service_provider*] |
| 1 | +# This class manages installation, configuration and execution of Logstash 5.x. |
| 2 | +# |
| 3 | +# @param [String] ensure |
| 4 | +# Controls if Logstash should be `present` or `absent`. |
| 5 | +# |
| 6 | +# If set to `absent`, the Logstash package will be |
| 7 | +# uninstalled. Related files will be purged as much as possible. The |
| 8 | +# exact behavior is dependant on the service provider, specifically its |
| 9 | +# support for the 'purgable' property. |
| 10 | +# |
| 11 | +# @param [Boolean] autoupgrade |
| 12 | +# If set to `true`, Logstash will be upgraded if the package provider is |
| 13 | +# able to find a newer version. The exact behavior is dependant on the |
| 14 | +# service provider, specifically its support for the 'upgradeable' property. |
| 15 | +# |
| 16 | +# @param [String] status |
| 17 | +# The desired state of the Logstash service. Possible values: |
| 18 | +# |
| 19 | +# - `enabled`: Service running and started at boot time. |
| 20 | +# - `disabled`: Service stopped and not started at boot time. |
| 21 | +# - `running`: Service running but not be started at boot time. |
| 22 | +# - `unmanaged`: Service will not be started at boot time. Puppet |
| 23 | +# will neither stop nor start the service. |
| 24 | +# |
| 25 | +# @param [String] version |
| 26 | +# The specific version to install, if desired. |
| 27 | +# |
| 28 | +# @param [Boolean] restart_on_change |
| 29 | +# Restart the service whenever the configuration changes. |
| 30 | +# |
| 31 | +# Disabling automatic restarts on config changes may be desired in an |
| 32 | +# environment where you need to ensure restarts occur in a |
| 33 | +# controlled/rolling manner rather than during a Puppet run. |
| 34 | +# |
| 35 | +# @param [String] package_url |
| 36 | +# Explict Logstash package URL to download. |
| 37 | +# |
| 38 | +# Valid URL types are: |
| 39 | +# - `http://` |
| 40 | +# - `https://` |
| 41 | +# - `ftp://` |
| 42 | +# - `puppet://` |
| 43 | +# - `file:/` |
| 44 | +# |
| 45 | +# @param [String] package_name |
| 46 | +# The name of the Logstash package in the package manager. |
| 47 | +# |
| 48 | +# @param [Integer] download_timeout |
| 49 | +# Timeout, in seconds, for http, https, and ftp downloads. |
| 50 | +# |
| 51 | +# @param [String] logstash_user |
| 52 | +# The user that Logstash should run as. This also controls file ownership. |
| 53 | +# |
| 54 | +# @param [String] logstash_group |
| 55 | +# The group that Logstash should run as. This also controls file group ownership. |
| 56 | +# |
| 57 | +# @param [Boolean] purge_configdir |
| 58 | +# Purge the config directory of any unmanaged files, |
| 59 | +# |
| 60 | +# @param [String] service_provider |
88 | 61 | # Service provider (init system) to use. By Default, the module will try to
|
89 | 62 | # choose the 'standard' provider for the current distribution.
|
90 | 63 | #
|
91 |
| -# [*settings*] |
92 |
| -# A hash of Logstash settings, to be defined in logstash.yml. |
| 64 | +# @param [Hash] settings |
| 65 | +# A collection of settings to be defined in `logstash.yml`. |
| 66 | +# |
93 | 67 | # See: https://www.elastic.co/guide/en/logstash/current/logstash-settings-file.html
|
94 | 68 | #
|
95 |
| -# [*startup_options*] |
96 |
| -# A hash of options used for running the Logstash process. |
97 |
| -# See: https://www.elastic.co/guide/en/logstash/current/config-setting-files.html |
| 69 | +# @param [Hash] startup_options |
| 70 | +# A collection of settings to be defined in `startup.options`. |
98 | 71 | #
|
99 |
| -# [*jvm_options*] |
100 |
| -# Array of options passed to the Java Virtual Machine. |
| 72 | +# See: https://www.elastic.co/guide/en/logstash/current/config-setting-files.html |
101 | 73 | #
|
102 |
| -# [*manage_repo*] |
103 |
| -# Enable repo management by enabling official repositories |
| 74 | +# @param [Array] jvm_options |
| 75 | +# A collection of settings to be defined in `jvm.options`. |
104 | 76 | #
|
105 |
| -# [*repo_version*] |
106 |
| -# Logstash repositories are versioned per major version (5.x) select here which version you want |
| 77 | +# @param [Boolean] manage_repo |
| 78 | +# Enable repository management. Configure the official repositories. |
107 | 79 | #
|
108 |
| -# [*configdir*] |
109 |
| -# Path to directory containing the logstash configuration. |
110 |
| -# Use this setting if your packages deviate from the norm (/etc/logstash) |
| 80 | +# @param [String] repo_version |
| 81 | +# Logstash repositories are defined by major version. Defines the major |
| 82 | +# version to manage. |
111 | 83 | #
|
112 |
| -# === Examples |
| 84 | +# @param [String] configdir |
| 85 | +# Path containing the Logstash configuration. |
113 | 86 | #
|
114 |
| -# * Installation, make sure service is running and will be started at boot time: |
115 |
| -# class { 'logstash': |
116 |
| -# manage_repo => true, |
117 |
| -# } |
| 87 | +# @example Install Logstash, ensure the service is running and enabled. |
| 88 | +# class { 'logstash': } |
118 | 89 | #
|
119 |
| -# * Removal/decommissioning: |
| 90 | +# @example Remove Logstash. |
120 | 91 | # class { 'logstash':
|
121 | 92 | # ensure => 'absent',
|
122 | 93 | # }
|
123 | 94 | #
|
124 |
| -# * Install everything but disable service(s) afterwards: |
| 95 | +# @example Install everything but disable the service. |
125 | 96 | # class { 'logstash':
|
126 | 97 | # status => 'disabled',
|
127 | 98 | # }
|
128 | 99 | #
|
129 |
| -# * Configure Logstash settings: |
| 100 | +# @example Configure Logstash settings. |
130 | 101 | # class { 'logstash':
|
131 | 102 | # settings => {
|
132 | 103 | # 'http.port' => '9700',
|
133 | 104 | # }
|
134 | 105 | # }
|
135 | 106 | #
|
136 |
| -# * Set JVM memory options: |
| 107 | +# @example Set JVM memory options. |
137 | 108 | # class { 'logstash':
|
138 | 109 | # jvm_options => [
|
139 | 110 | # '-Xms1g',
|
140 | 111 | # '-Xmx1g',
|
141 | 112 | # ]
|
142 | 113 | # }
|
143 | 114 | #
|
144 |
| -# === Authors |
145 |
| -# |
146 |
| -# https://github.com/elastic/puppet-logstash/graphs/contributors |
| 115 | +# @author https://github.com/elastic/puppet-logstash/graphs/contributors |
147 | 116 | #
|
148 | 117 | class logstash(
|
149 |
| - $ensure = $logstash::params::ensure, |
150 |
| - $status = $logstash::params::status, |
151 |
| - $restart_on_change = $logstash::params::restart_on_change, |
152 |
| - $autoupgrade = $logstash::params::autoupgrade, |
153 |
| - $version = false, |
| 118 | + $ensure = 'present', |
| 119 | + $status = 'enabled', |
| 120 | + $restart_on_change = true, |
| 121 | + $autoupgrade = false, |
| 122 | + $version = undef, |
154 | 123 | $package_url = undef,
|
155 |
| - $package_name = $logstash::params::package_name, |
156 |
| - $download_timeout = $logstash::params::download_timeout, |
157 |
| - $logstash_user = $logstash::params::logstash_user, |
158 |
| - $logstash_group = $logstash::params::logstash_group, |
159 |
| - $configdir = $logstash::params::configdir, |
160 |
| - $purge_configdir = $logstash::params::purge_configdir, |
| 124 | + $package_name = 'logstash', |
| 125 | + $download_timeout = 600, |
| 126 | + $logstash_user = 'logstash', |
| 127 | + $logstash_group = 'logstash', |
| 128 | + $configdir = '/etc/logstash', |
| 129 | + $purge_configdir = false, |
161 | 130 | $service_provider = undef,
|
162 | 131 | $settings = {},
|
163 | 132 | $startup_options = {},
|
164 | 133 | $jvm_options = [],
|
165 | 134 | $manage_repo = true,
|
166 |
| - $repo_version = $logstash::params::repo_version, |
167 |
| -) inherits logstash::params { |
168 |
| - |
| 135 | + $repo_version = '5.x', |
| 136 | +) |
| 137 | +{ |
169 | 138 | #### Validate parameters
|
170 | 139 | validate_bool($autoupgrade)
|
171 | 140 | validate_bool($restart_on_change)
|
|
184 | 153 | fail("\"${status}\" is not a valid status parameter value")
|
185 | 154 | }
|
186 | 155 |
|
187 |
| - if ($package_url != undef and $version != false) { |
188 |
| - fail('Unable to set the version number when using package_url option.') |
189 |
| - } |
190 |
| - |
191 | 156 | if ($manage_repo == true) {
|
192 | 157 | validate_string($repo_version)
|
193 | 158 | }
|
|
0 commit comments