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',
  ]
}

Configure multiple pipelines.

class { 'logstash':
  pipelines => [
    {
      "pipeline.id" => "my-pipeline_1",
      "path.config" =>  "/etc/path/to/p1.config",
    },
    {
      "pipeline.id" => "my-other-pipeline",
      "path.config" =>  "/etc/different/path/p2.cfg",
    }
  ]
}

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.

  • home_dir (Stdlib::Absolutepath) (defaults to: '/usr/share/logstash')

    The home directory for logstash.

  • 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 (Optional[String[1]]) (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: 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: www.elastic.co/guide/en/logstash/current/config-setting-files.html

  • jvm_options_defaults (Hash) (defaults to: { '-Xms' => '-Xms1g', '-Xmx' => '-Xmx1g', 'UseConcMarkSweepGC' => '11-13:-XX:+UseConcMarkSweepGC', 'CMSInitiatingOccupancyFraction=' => '11-13:-XX:CMSInitiatingOccupancyFraction=75', 'UseCMSInitiatingOccupancyOnly' => '11-13:-XX:+UseCMSInitiatingOccupancyOnly', '-Djava.awt.headless=' => '-Djava.awt.headless=true', '-Dfile.encoding=' => '-Dfile.encoding=UTF-8', 'HeapDumpOnOutOfMemoryError' => '-XX:+HeapDumpOnOutOfMemoryError', '-Djava.security.egd' => '-Djava.security.egd=file:/dev/urandom', })

    Default set of optionname => option mappings from upstream 8.5 version

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

    A collection of settings to be defined in ‘jvm.options`. Override same settings in jvm_options_defaults

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

    A collection of settings to be defined in ‘pipelines.yml`.

  • manage_repo (Boolean) (defaults to: true)

    Enable repository management. Configure the official repositories.

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

    Path containing the Logstash configuration.

Author:



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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'manifests/init.pp', line 143

class logstash (
  $ensure            = 'present',
  $status            = 'enabled',
  Boolean $restart_on_change = true,
  Boolean $auto_upgrade       = false,
  $version           = undef,
  $package_url       = undef,
  $package_name      = 'logstash',
  Integer $download_timeout  = 600,
  Stdlib::Absolutepath $home_dir = '/usr/share/logstash',
  $logstash_user     = 'logstash',
  $logstash_group    = 'logstash',
  $config_dir         = '/etc/logstash',
  Boolean $purge_config = true,
  Optional[String[1]] $service_provider = undef,
  $settings          = {},
  $startup_options   = {},
  $jvm_options_defaults = {
    '-Xms' => '-Xms1g',
    '-Xmx' => '-Xmx1g',
    'UseConcMarkSweepGC' => '11-13:-XX:+UseConcMarkSweepGC',
    'CMSInitiatingOccupancyFraction=' => '11-13:-XX:CMSInitiatingOccupancyFraction=75',
    'UseCMSInitiatingOccupancyOnly' => '11-13:-XX:+UseCMSInitiatingOccupancyOnly',
    '-Djava.awt.headless=' => '-Djava.awt.headless=true',
    '-Dfile.encoding=' => '-Dfile.encoding=UTF-8',
    'HeapDumpOnOutOfMemoryError' => '-XX:+HeapDumpOnOutOfMemoryError',
    '-Djava.security.egd' => '-Djava.security.egd=file:/dev/urandom',
  },
  $jvm_options       = [],
  Array $pipelines   = [],
  Boolean $manage_repo   = true,
) {
  if ! ($ensure in ['present', 'absent']) {
    fail("\"${ensure}\" is not a valid ensure parameter value")
  }

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

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