Documentation by YARD 0.9.13
-Alphabetic Index
- -Puppet Class Listing A-Z
- - -
-
-
-
|
-
Defined Type Listing A-Z
- - -
-
-
-
|
-
File Listing
--
-
-
-
- README - - -
-
-
-
|
-
-
-
-
|
-
| t |
- - - -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 -174- |
-
- # File 'manifests/init.pp', line 137
-
-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,
- $logstash_user = 'logstash',
- $logstash_group = 'logstash',
- $config_dir = '/etc/logstash',
- Boolean $purge_config = true,
- $service_provider = undef,
- $settings = {},
- $startup_options = {},
- $jvm_options = [],
- Array $pipelines = [],
- Boolean $manage_repo = true,
-)
-{
- $home_dir = '/usr/share/logstash'
-
- 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
-}
- |
-
This class manages configuration directories for Logstash.
- -
- - - -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50- |
-
- # File 'manifests/config.pp', line 8
-
-class logstash::config {
- require logstash::package
-
- File {
- owner => 'root',
- group => 'root',
- }
-
- # Configuration "fragment" directories for pipeline config and pattern files.
- # We'll keep these seperate since we may want to "purge" them. It's easy to
- # end up with orphan files when managing config fragments with Puppet.
- # Purging the directories resolves the problem.
-
- if($logstash::ensure == 'present') {
- file { $logstash::config_dir:
- ensure => directory,
- mode => '0755',
- }
-
- file { "${logstash::config_dir}/conf.d":
- ensure => directory,
- purge => $logstash::purge_config,
- recurse => $logstash::purge_config,
- mode => '0775',
- notify => Service['logstash'],
- }
-
- file { "${logstash::config_dir}/patterns":
- ensure => directory,
- purge => $logstash::purge_config,
- recurse => $logstash::purge_config,
- mode => '0755',
- }
- }
- elsif($logstash::ensure == 'absent') {
- # Completely remove the config directory. ie. 'rm -rf /etc/logstash'
- file { $logstash::config_dir:
- ensure => 'absent',
- recurse => true,
- force => true,
- }
- }
-}
- |
-
This class manages the Logstash package.
- -It is usually used only by the top-level logstash class. It's unlikely
-that you will need to declare this class yourself.
- - - -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -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- |
-
- # File 'manifests/package.pp', line 20
-
-class logstash::package(
- $package_url = $logstash::package_url,
- $version = $logstash::version,
- $package_name = $logstash::package_name,
-)
-{
- Exec {
- path => [ '/bin', '/usr/bin', '/usr/local/bin' ],
- cwd => '/',
- tries => 3,
- try_sleep => 10,
- }
-
- File {
- ensure => file,
- backup => false,
- }
-
- if $logstash::ensure == 'present' {
- # Check if we want to install a specific version.
- if $version {
- if $::osfamily == 'redhat' {
- # Prerelease RPM packages have tildes ("~") in their version strings,
- # which can be quite surprising to the user. Let them say:
- # 6.0.0-rc2
- # not:
- # 6.0.0~rc2
- $package_ensure = regsubst($version, '(\d+)-(alpha|beta|rc)(\d+)$', '\1~\2\3')
- }
- else {
- $package_ensure = $version
- }
- }
- else {
- $package_ensure = $logstash::auto_upgrade ? {
- true => 'latest',
- false => 'present',
- }
- }
-
- if ($package_url) {
- $filename = basename($package_url)
- $extension = regsubst($filename, '.*\.', '')
- $protocol = regsubst($package_url, ':.*', '')
- $package_local_file = "/tmp/${filename}"
-
- case $protocol {
- 'puppet': {
- file { $package_local_file:
- source => $package_url,
- }
- }
- 'ftp', 'https', 'http': {
- exec { "download_package_logstash_${name}":
- command => "wget -O ${package_local_file} ${package_url} 2> /dev/null",
- path => ['/usr/bin', '/bin'],
- creates => $package_local_file,
- timeout => $logstash::download_timeout,
- }
- }
- 'file': {
- file { $package_local_file:
- source => $package_url,
- }
- }
- default: {
- fail("Protocol must be puppet, file, http, https, or ftp. Not '${protocol}'")
- }
- }
-
- case $extension {
- 'deb': { $package_provider = 'dpkg' }
- 'rpm': { $package_provider = 'rpm' }
- default: { fail("Unknown file extension '${extension}'.") }
- }
-
- $package_require = undef
- }
- else {
- # Use the OS packaging system to locate the package.
- $package_local_file = undef
- $package_provider = undef
- if $::osfamily == 'Debian' {
- $package_require = $logstash::manage_repo ? {
- true => Class['apt::update'],
- false => undef,
- }
- } else {
- $package_require = undef
- }
- }
- }
- else { # Package removal
- $package_local_file = undef
- $package_require = undef
- if ($::osfamily == 'Suse') {
- $package_provider = 'rpm'
- $package_ensure = 'absent' # "purged" not supported by provider
- }
- else {
- $package_provider = undef # ie. automatic
- $package_ensure = 'purged'
- }
- }
-
- package { 'logstash':
- ensure => $package_ensure,
- name => $package_name,
- source => $package_local_file, # undef if using package manager.
- provider => $package_provider, # undef if using package manager.
- require => $package_require,
- }
-}
- |
-
This mangages the system service for Logstash.
- -It is usually used only by the top-level logstash class. It's unlikely
-that you will need to declare this class yourself.
- - - -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -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/service.pp', line 11
-
-class logstash::service {
- $default_settings = {
- 'path.data' => '/var/lib/logstash',
- 'path.config' => '/etc/logstash/conf.d',
- 'path.logs' => '/var/log/logstash',
- }
-
- $default_startup_options = {
- 'JAVACMD' => '/usr/bin/java',
- 'LS_HOME' => $logstash::home_dir,
- 'LS_SETTINGS_DIR' => $logstash::config_dir,
- 'LS_OPTS' => "--path.settings=${logstash::config_dir}",
- 'LS_JAVA_OPTS' => '""',
- 'LS_PIDFILE' => '/var/run/logstash.pid',
- 'LS_USER' => $logstash::logstash_user,
- 'LS_GROUP' => $logstash::logstash_group,
- 'LS_GC_LOG_FILE' => '/var/log/logstash/gc.log',
- 'LS_OPEN_FILES' => '16384',
- 'LS_NICE' => '19',
- 'SERVICE_NAME' => '"logstash"',
- 'SERVICE_DESCRIPTION' => '"logstash"',
- }
-
- $default_jvm_options = [
- '-Dfile.encoding=UTF-8',
- '-Djava.awt.headless=true',
- '-Xms256m',
- '-Xmx1g',
- '-XX:CMSInitiatingOccupancyFraction=75',
- '-XX:+DisableExplicitGC',
- '-XX:+HeapDumpOnOutOfMemoryError',
- '-XX:+UseCMSInitiatingOccupancyOnly',
- '-XX:+UseConcMarkSweepGC',
- '-XX:+UseParNewGC',
- ]
-
- $settings = merge($default_settings, $logstash::settings)
- $startup_options = merge($default_startup_options, $logstash::startup_options)
- $jvm_options = $logstash::jvm_options
- $pipelines = $logstash::pipelines
-
- File {
- owner => 'root',
- group => 'root',
- mode => '0644',
- notify => Exec['logstash-system-install'],
- }
-
- if $logstash::ensure == 'present' {
- case $logstash::status {
- 'enabled': {
- $service_ensure = 'running'
- $service_enable = true
- }
- 'disabled': {
- $service_ensure = 'stopped'
- $service_enable = false
- }
- 'running': {
- $service_ensure = 'running'
- $service_enable = false
- }
- default: {
- fail("\"${logstash::status}\" is an unknown service status value")
- }
- }
- } else {
- $service_ensure = 'stopped'
- $service_enable = false
- }
-
- if $service_ensure == 'running' {
- # Then make sure the Logstash startup options are up to date.
- file {'/etc/logstash/startup.options':
- content => template('logstash/startup.options.erb'),
- }
-
- # ..and make sure the JVM options are up to date.
- file {'/etc/logstash/jvm.options':
- content => template('logstash/jvm.options.erb'),
- }
-
- # ..and pipelines.yml, if the user provided such. If they didn't, zero out
- # the file, which will default Logstash to traditional single-pipeline
- # behaviour.
- if(empty($pipelines)) {
- file {'/etc/logstash/pipelines.yml':
- content => '',
- }
- }
- else {
- file {'/etc/logstash/pipelines.yml':
- content => template('logstash/pipelines.yml.erb'),
- }
- }
-
- # ..and the Logstash internal settings too.
- file {'/etc/logstash/logstash.yml':
- content => template('logstash/logstash.yml.erb'),
- }
-
- # Invoke 'system-install', which generates startup scripts based on the
- # contents of the 'startup.options' file.
- exec { 'logstash-system-install':
- command => "${logstash::home_dir}/bin/system-install",
- refreshonly => true,
- notify => Service['logstash'],
- }
- }
-
- # Figure out which service provider (init system) we should be using.
- # In general, we'll try to guess based on the operating system.
- $os = downcase($::operatingsystem)
- $release = $::operatingsystemmajrelease
- # However, the operator may have explicitly defined the service provider.
- if($logstash::service_provider) {
- $service_provider = $logstash::service_provider
- }
- # In the absence of an explicit choice, we'll try to figure out a sensible
- # default.
- # Puppet 3 doesn't know that Debian 8 uses systemd, not SysV init, so we'll
- # help it out with our knowledge from the future.
- elsif($os == 'debian' and $release == '8') {
- $service_provider = 'systemd'
- }
- # Centos 6 uses Upstart by default, but Puppet can get confused about this too.
- elsif($os =~ /(redhat|centos)/ and $release == '6') {
- $service_provider = 'upstart'
- }
- elsif($os =~ /ubuntu/ and $release == '12.04') {
- $service_provider = 'upstart'
- }
- elsif($os =~ /opensuse/ and $release == '13') {
- $service_provider = 'systemd'
- }
- #Older Amazon Linux AMIs has its release based on the year
- #it came out (2010 and up); the provider needed to be set explicitly;
- #New Amazon Linux 2 AMIs has the release set to 2, Puppet can handle it
- elsif($os =~ /amazon/ and versioncmp($release, '2000') > 0) {
- $service_provider = 'upstart'
- }
- else {
- # In most cases, Puppet(4) can figure out the correct service
- # provider on its own, so we'll just say 'undef', and let it do
- # whatever it thinks is best.
- $service_provider = undef
- }
-
- service { 'logstash':
- ensure => $service_ensure,
- enable => $service_enable,
- hasstatus => true,
- hasrestart => true,
- provider => $service_provider,
- }
-
- # If any files tagged as config files for the service are changed, notify
- # the service so it restarts.
- if $::logstash::restart_on_change {
- File<| tag == 'logstash_config' |> ~> Service['logstash']
- Logstash::Plugin<| |> ~> Service['logstash']
- }
-}
- |
-
This type represents a Logstash pipeline configuration file.
- -Parameters are mutually exclusive. Only one should be specified.
- -
- - - -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86- |
-
- # File 'manifests/configfile.pp', line 44
-
-define logstash::configfile(
- $content = undef,
- $source = undef,
- $template = undef,
- $path = undef,
-)
-{
- include logstash
-
- $owner = 'root'
- $group = $logstash::logstash_group
- $mode = '0640'
- $require = Package['logstash'] # So that we have '/etc/logstash/conf.d'.
- $tag = [ 'logstash_config' ] # So that we notify the service.
-
- if($template) { $config = template($template) }
- elsif($content) { $config = $content }
- else { $config = undef }
-
- if($path) { $config_file = $path }
- else { $config_file = "${logstash::config_dir}/conf.d/${name}" }
-
- if($config) {
- file { $config_file:
- content => $config,
- owner => $owner,
- group => $group,
- mode => $mode,
- require => $require,
- tag => $tag,
- }
- }
- elsif($source) {
- file { $config_file:
- source => $source,
- owner => $owner,
- group => $group,
- mode => $mode,
- require => $require,
- tag => $tag,
- }
- }
-}
- |
-
This type represents a Grok pattern file for Logstash.
- -
- - - -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40- |
-
- # File 'manifests/patternfile.pp', line 22
-
-define logstash::patternfile ($source = undef, $filename = undef) {
- require logstash::config
-
- validate_re($source, '^(puppet|file)://',
- 'Source must begin with "puppet://" or "file://")'
- )
-
- if($filename) { $destination = $filename }
- else { $destination = basename($source) }
-
- file { "${logstash::config_dir}/patterns/${destination}":
- ensure => file,
- source => $source,
- owner => 'root',
- group => $logstash::logstash_group,
- mode => '0640',
- tag => ['logstash_config'],
- }
-}
- |
-
Manage the installation of a Logstash plugin.
- -By default, plugins are downloaded from RubyGems, but it is also possible -to install from a local Gem, or one stored in Puppet.
- -
- - - -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -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- |
-
- # File 'manifests/plugin.pp', line 40
-
-define logstash::plugin (
- $source = undef,
- $ensure = present,
- $environment = [],
-)
-{
- require logstash::package
- $exe = "${logstash::home_dir}/bin/logstash-plugin"
-
- Exec {
- path => '/bin:/usr/bin',
- cwd => '/tmp',
- user => $logstash::logstash_user,
- timeout => 1800,
- environment => $environment,
- }
-
- case $source { # Where should we get the plugin from?
- undef: {
- # No explict source, so search Rubygems for the plugin, by name.
- # ie. "logstash-plugin install logstash-output-elasticsearch"
- $plugin = $name
- }
-
- /^(\/|file:)/: {
- # A gem file that is already available on the local filesystem.
- # Install from the local path.
- # ie. "logstash-plugin install /tmp/logtash-filter-custom.gem" or
- # "logstash-plugin install file:///tmp/logtash-filter-custom.gem" or
- $plugin = $source
- }
-
- /^puppet:/: {
- # A 'puppet:///' URL. Download the gem from Puppet, then install
- # the plugin from the downloaded file.
- $downloaded_file = sprintf('/tmp/%s', basename($source))
- file { $downloaded_file:
- source => $source,
- before => Exec["install-${name}"],
- }
-
- case $source {
- /\.zip$/: {
- $plugin = "file://${downloaded_file}"
- }
- default: {
- $plugin = $downloaded_file
- }
- }
- }
-
- /^https?:/: {
- # An 'http(s):///' URL.
- $plugin = $source
- }
-
- default: {
- fail('"source" should be a local path, a "puppet:///" url, or undef.')
- }
- }
-
- case $ensure {
- 'present': {
- exec { "install-${name}":
- command => "${exe} install ${plugin}",
- unless => "${exe} list ^${name}$",
- }
- }
-
- /^\d+\.\d+\.\d+/: {
- exec { "install-${name}":
- command => "${exe} install --version ${ensure} ${plugin}",
- unless => "${exe} list --verbose ^${name}$ | grep --fixed-strings --quiet '(${ensure})'",
- }
- }
-
- 'absent': {
- exec { "remove-${name}":
- command => "${exe} remove ${name}",
- onlyif => "${exe} list | grep -q ^${name}$",
- }
- }
-
- default: {
- fail "'ensure' should be 'present', 'absent', or a version like '1.3.4'."
- }
- }
-}
- |
-