Puppet Class: logstash

Defined in:
manifests/init.pp

Overview

This class manages installation, configuration and execution of Logstash 5.x.

Examples:

Install Logstash, ensure the service is running and enabled.

class { 'logstash': }

Remove Logstash.

class { 'logstash':
  ensure => 'absent',
}

Install everything but disable the service.

class { 'logstash':
  status => 'disabled',
}

Configure Logstash settings.

class { 'logstash':
  settings => {
    'http.port' => '9700',
  }
}

Configure Logstash startup options.

class { 'logstash':
  startup_options => {
    'LS_USER' => 'root',
  }
}

Set JVM memory options.

class { 'logstash':
  jvm_options => [
    '-Xms1g',
    '-Xmx1g',
  ]
}

Parameters:

  • ensure (String) (defaults to: 'present')

    Controls if Logstash should be present or absent.

    If set to absent, the Logstash package will be uninstalled. Related files will be purged as much as possible. The exact behavior is dependant on the service provider, specifically its support for the 'purgable' property.

  • auto_upgrade (Boolean) (defaults to: false)

    If set to true, Logstash will be upgraded if the package provider is able to find a newer version. The exact behavior is dependant on the service provider, specifically its support for the 'upgradeable' property.

  • status (String) (defaults to: 'enabled')

    The desired state of the Logstash service. Possible values:

    • enabled: Service running and started at boot time.
    • disabled: Service stopped and not started at boot time.
    • running: Service running but not be started at boot time.
    • unmanaged: Service will not be started at boot time. Puppet will neither stop nor start the service.
  • version (String) (defaults to: undef)

    The specific version to install, if desired.

  • restart_on_change (Boolean) (defaults to: true)

    Restart the service whenever the configuration changes.

    Disabling automatic restarts on config changes may be desired in an environment where you need to ensure restarts occur in a controlled/rolling manner rather than during a Puppet run.

  • package_url (String) (defaults to: undef)

    Explict Logstash package URL to download.

    Valid URL types are:

    • http://
    • https://
    • ftp://
    • puppet://
    • file:/
  • package_name (String) (defaults to: 'logstash')

    The name of the Logstash package in the package manager.

  • download_timeout (Integer) (defaults to: 600)

    Timeout, in seconds, for http, https, and ftp downloads.

  • logstash_user (String) (defaults to: 'logstash')

    The user that Logstash should run as. This also controls file ownership.

  • logstash_group (String) (defaults to: 'logstash')

    The group that Logstash should run as. This also controls file group ownership.

  • purge_config (Boolean) (defaults to: true)

    Purge the config directory of any unmanaged files,

  • service_provider (String) (defaults to: undef)

    Service provider (init system) to use. By Default, the module will try to choose the 'standard' provider for the current distribution.

  • settings (Hash) (defaults to: {})

    A collection of settings to be defined in logstash.yml.

    See: https://www.elastic.co/guide/en/logstash/current/logstash-settings-file.html

  • startup_options (Hash) (defaults to: {})

    A collection of settings to be defined in startup.options.

    See: https://www.elastic.co/guide/en/logstash/current/config-setting-files.html

  • jvm_options (Array) (defaults to: [])

    A collection of settings to be defined in jvm.options.

  • manage_repo (Boolean) (defaults to: true)

    Enable repository management. Configure the official repositories.

  • repo_version (String) (defaults to: '5.x')

    Logstash repositories are defined by major version. Defines the major version to manage.

  • config_dir (String) (defaults to: '/etc/logstash')

    Path containing the Logstash configuration.

Author:



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
# File 'manifests/init.pp', line 124

class logstash(
  $ensure            = 'present',
  $status            = 'enabled',
  $restart_on_change = true,
  $auto_upgrade       = false,
  $version           = undef,
  $package_url       = undef,
  $package_name      = 'logstash',
  $download_timeout  = 600,
  $logstash_user     = 'logstash',
  $logstash_group    = 'logstash',
  $config_dir         = '/etc/logstash',
  $purge_config      = true,
  $service_provider  = undef,
  $settings          = {},
  $startup_options   = {},
  $jvm_options       = [],
  $manage_repo       = true,
  $repo_version      = '5.x',
)
{
  $home_dir = '/usr/share/logstash'

  validate_bool($auto_upgrade)
  validate_bool($restart_on_change)
  validate_bool($purge_config)
  validate_bool($manage_repo)

  if ! ($ensure in [ 'present', 'absent' ]) {
    fail("\"${ensure}\" is not a valid ensure parameter value")
  }

  if ! is_integer($download_timeout) {
    fail("\"${download_timeout}\" is not a valid number for 'download_timeout' parameter")
  }

  if ! ($status in [ 'enabled', 'disabled', 'running', 'unmanaged' ]) {
    fail("\"${status}\" is not a valid status parameter value")
  }


  if ($manage_repo == true) {
    validate_string($repo_version)
    include logstash::repo
  }
  include logstash::package
  include logstash::config
  include logstash::service
}