Puppet Class: logstash
- Inherits:
- logstash::params
- Defined in:
- manifests/init.pp
Overview
Class: logstash
This class is able to install or remove logstash on a node. It manages the status of the related service.
Parameters
- ensure
-
String. Controls if the managed resources shall be
present
orabsent
. If set toabsent
:-
The managed software packages are being uninstalled.
-
Any traces of the packages will be purged as good as possible. This may include existing configuration files. The exact behavior is provider dependent. Q.v.:
-
Puppet type reference: package, “purgeable”
-
-
System modifications (if any) will be reverted as good as possible (e.g. removal of created users, services, changed log settings, …).
-
This is thus destructive and should be used with care.
Defaults to
present
. -
- autoupgrade
-
Boolean. If set to
true
, any managed package gets upgraded on each Puppet run when the package provider is able to find a newer version than the present one. The exact behavior is provider dependent. Q.v.:-
Puppet type reference: package, “upgradeable”
Defaults to
false
. -
- status
-
String to define the status of the service. Possible values:
-
enabled
: Service is running and will be started at boot time. -
disabled
: Service is stopped and will not be started at boot time. -
running
: Service is running but will not be started at boot time. You can use this to start a service on the first Puppet run instead of the system startup. -
unmanaged
: Service will not be started at boot time and Puppet does not care whether the service is running or not. For example, this may be useful if a cluster management software is used to decide when to start the service plus assuring it is running on the desired node.
Defaults to
enabled
. The singular form (“service”) is used for the sake of convenience. Of course, the defined status affects all services if more than one is managed (seeservice.pp
to check if this is the case). -
- version
-
String to set the specific version you want to install. Defaults to
false
.
The default values for the parameters are set in logstash::params. Have a look at the corresponding params.pp
manifest file if you need more technical information about them.
Examples
-
Installation, make sure service is running and will be started at boot time:
class { 'logstash': }
-
Removal/decommissioning:
class { 'logstash': ensure => 'absent', }
-
Install everything but disable service(s) afterwards
class { 'logstash': status => 'disabled', }
Authors
-
Richard Pijnenburg <richard@ispavailability.com>
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 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'manifests/init.pp', line 78
class logstash(
$ensure = $logstash::params::ensure,
$autoupgrade = $logstash::params::autoupgrade,
$status = $logstash::params::status,
$version = false,
$provider = 'package',
$jarfile = undef,
$installpath = $logstash::params::installpath,
$java_install = false,
$java_package = undef,
$instances = [ 'agent' ],
$multi_instance = true,
$initfiles = undef,
$defaultsfiles = undef,
$logstash_user = $logstash::params::logstash_user,
$logstash_group = $logstash::params::logstash_group
) inherits logstash::params {
anchor {'logstash::begin': }
anchor {'logstash::end': }
#### Validate parameters
# ensure
if ! ($ensure in [ 'present', 'absent' ]) {
fail("\"${ensure}\" is not a valid ensure parameter value")
}
# autoupgrade
validate_bool($autoupgrade)
# service status
if ! ($status in [ 'enabled', 'disabled', 'running', 'unmanaged' ]) {
fail("\"${status}\" is not a valid status parameter value")
}
if $initfiles {
if $multi_instance == true {
validate_hash($initfiles)
} else {
validate_string($initfiles)
}
}
if $defaultsfiles {
if $multi_instance == true {
validate_hash($defaultsfiles)
} else {
validate_string($defaultsfiles)
}
}
#### Manage actions
# package(s)
class { 'logstash::package': }
# configuration
class { 'logstash::config': }
# service(s)
class { 'logstash::service': }
if $java_install == true {
# Install java
class { 'logstash::java': }
# ensure we first java java and then manage the service
Anchor['logstash::begin']
-> Class['logstash::java']
-> Class['logstash::service']
}
#### Manage relationships
if $ensure == 'present' {
# we need the software before configuring it
Anchor['logstash::begin']
-> Class['logstash::package']
-> Class['logstash::config']
# we need the software and a working configuration before running a service
Class['logstash::package'] -> Class['logstash::service']
Class['logstash::config'] -> Class['logstash::service']
Class['logstash::service'] -> Anchor['logstash::end']
} else {
# make sure all services are getting stopped before software removal
Anchor['logstash::begin']
-> Class['logstash::service']
-> Class['logstash::package']
-> Anchor['logstash::end']
}
}
|