Skip to content

Commit 9d829ba

Browse files
author
Toby McLaughlin
committed
Begin move to puppet-strings. Remove params class.
1 parent 6c7a3d9 commit 9d829ba

File tree

8 files changed

+150
-269
lines changed

8 files changed

+150
-269
lines changed

.projectile

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
-/doc
2+
-/.vendor

manifests/config.pp

+7-7
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@
4848
}
4949

5050
$directories = [
51-
$logstash::patterndir,
52-
$logstash::plugindir,
53-
"${logstash::plugindir}/logstash",
54-
"${logstash::plugindir}/logstash/inputs",
55-
"${logstash::plugindir}/logstash/outputs",
56-
"${logstash::plugindir}/logstash/filters",
57-
"${logstash::plugindir}/logstash/codecs",
51+
"${logstash::configdir}/patterns",
52+
"${logstash::configdir}/plugins",
53+
"${logstash::configdir}/plugins/logstash",
54+
"${logstash::configdir}/plugins/logstash/inputs",
55+
"${logstash::configdir}/plugins/logstash/outputs",
56+
"${logstash::configdir}/plugins/logstash/filters",
57+
"${logstash::configdir}/plugins/logstash/codecs",
5858
]
5959

6060
file { $directories:,

manifests/configfile.pp

+22-29
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,35 @@
1-
# == define: logstash::configfile
1+
# This type represents a Logstash pipeline configuration file.
22
#
3-
# This define is to manage the pipeline configuration files for Logstash.
3+
# Parameters are mutually exclusive. Only one should be specified.
44
#
5-
# === Parameters
6-
# One of following:
5+
# @param [String] content
6+
# Literal content to be placed in the file.
77
#
8-
# [*content*]
9-
# Literal content to be used for the config file.
8+
# @param [String] template
9+
# A template from which to render the file.
1010
#
11-
# [*template*]
12-
# Location of template from which to render a config file.
11+
# @param [String] source
12+
# A file resource to be used for the file.
1313
#
14-
# [*source*]
15-
# A file resource to be used for the config file.
14+
# @example Create a config file content with literal content.
1615
#
17-
# === Examples
16+
# logstash::configfile { 'heartbeat':
17+
# content => 'input { heartbeat {} }',
18+
# }
1819
#
19-
# Set config file content with a literal value:
20+
# @example Render a config file from a template.
2021
#
21-
# logstash::configfile { 'heartbeat':
22-
# content => 'input { heartbeat {} }',
23-
# }
22+
# logstash::configfile { 'from-template':
23+
# template => 'site-logstash-module/pipeline-config.erb',
24+
# }
2425
#
25-
# ...from a template:
26+
# @example Copy the config from a file source.
2627
#
27-
# logstash::configfile { 'from-template':
28-
# template => 'site-logstash-module/pipeline-config.erb',
29-
# }
28+
# logstash::configfile { 'apache':
29+
# source => 'puppet://path/to/apache.conf',
30+
# }
3031
#
31-
# ...or from a file source:
32-
#
33-
# logstash::configfile { 'apache':
34-
# source => 'puppet://path/to/apache.conf',
35-
# }
36-
#
37-
# === Authors
38-
#
39-
# https://github.com/elastic/puppet-logstash/graphs/contributors
32+
# @author https://github.com/elastic/puppet-logstash/graphs/contributors
4033
#
4134
define logstash::configfile(
4235
$content = undef,
@@ -46,7 +39,7 @@
4639
{
4740
include logstash
4841

49-
$path = "/etc/logstash/conf.d/${name}.conf"
42+
$path = "${logstash::configdir}/conf.d/${name}.conf"
5043
$owner = $logstash::logstash_user
5144
$group = $logstash::logstash_group
5245
$mode ='0440'

manifests/init.pp

+96-131
Original file line numberDiff line numberDiff line change
@@ -1,171 +1,140 @@
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
8861
# Service provider (init system) to use. By Default, the module will try to
8962
# choose the 'standard' provider for the current distribution.
9063
#
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+
#
9367
# See: https://www.elastic.co/guide/en/logstash/current/logstash-settings-file.html
9468
#
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`.
9871
#
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
10173
#
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`.
10476
#
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.
10779
#
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.
11183
#
112-
# === Examples
84+
# @param [String] configdir
85+
# Path containing the Logstash configuration.
11386
#
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': }
11889
#
119-
# * Removal/decommissioning:
90+
# @example Remove Logstash.
12091
# class { 'logstash':
12192
# ensure => 'absent',
12293
# }
12394
#
124-
# * Install everything but disable service(s) afterwards:
95+
# @example Install everything but disable the service.
12596
# class { 'logstash':
12697
# status => 'disabled',
12798
# }
12899
#
129-
# * Configure Logstash settings:
100+
# @example Configure Logstash settings.
130101
# class { 'logstash':
131102
# settings => {
132103
# 'http.port' => '9700',
133104
# }
134105
# }
135106
#
136-
# * Set JVM memory options:
107+
# @example Set JVM memory options.
137108
# class { 'logstash':
138109
# jvm_options => [
139110
# '-Xms1g',
140111
# '-Xmx1g',
141112
# ]
142113
# }
143114
#
144-
# === Authors
145-
#
146-
# https://github.com/elastic/puppet-logstash/graphs/contributors
115+
# @author https://github.com/elastic/puppet-logstash/graphs/contributors
147116
#
148117
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,
154123
$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,
161130
$service_provider = undef,
162131
$settings = {},
163132
$startup_options = {},
164133
$jvm_options = [],
165134
$manage_repo = true,
166-
$repo_version = $logstash::params::repo_version,
167-
) inherits logstash::params {
168-
135+
$repo_version = '5.x',
136+
)
137+
{
169138
#### Validate parameters
170139
validate_bool($autoupgrade)
171140
validate_bool($restart_on_change)
@@ -184,10 +153,6 @@
184153
fail("\"${status}\" is not a valid status parameter value")
185154
}
186155

187-
if ($package_url != undef and $version != false) {
188-
fail('Unable to set the version number when using package_url option.')
189-
}
190-
191156
if ($manage_repo == true) {
192157
validate_string($repo_version)
193158
}

0 commit comments

Comments
 (0)