Showing with 226 additions and 33 deletions.
  1. +15 −1 CHANGELOG.md
  2. +5 −0 README.md
  3. +6 −1 lib/facter/filebeat_version.rb
  4. +42 −10 manifests/config.pp
  5. +5 −1 manifests/init.pp
  6. +32 −8 manifests/input.pp
  7. +6 −0 manifests/install.pp
  8. +6 −0 manifests/install/sunos.pp
  9. +30 −2 manifests/params.pp
  10. +1 −1 manifests/service.pp
  11. +7 −6 metadata.json
  12. +1 −0 templates/filebeat.yml.erb
  13. +70 −3 templates/input.yml.erb
16 changes: 15 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,21 @@ Changelog
=========

## Unreleased
[Full Changelog](https://github.com/pcfens/puppet-filebeat/compare/v4.11.0...HEAD)
[Full Changelog](https://github.com/pcfens/puppet-filebeat/compare/v4.12.0...HEAD)

## [v4.12.0](https://github.com/pcfens/puppet-filebeat/tree/v4.12.0)
[Full Changelog](https://github.com/pcfens/puppet-filebeat/compare/v4.11.0...v4.12.0)

- Various lint and bugfixes
- Add filestream support [\#303](https://github.com/pcfens/puppet-filebeat/pull/303)
- Add journald support [\#302](https://github.com/pcfens/puppet-filebeat/pull/302)
- Add syslog support [\#301](https://github.com/pcfens/puppet-filebeat/pull/301)
- Allow Filebeat 8 to be installed [\#300](https://github.com/pcfens/puppet-filebeat/pull/300)
- Add `filebeat.overwrite_pipelines` option [\#286](https://github.com/pcfens/puppet-filebeat/pull/286)
- Fix autodiscover apply location [\#291](https://github.com/pcfens/puppet-filebeat/pull/291)
- Add SSL support for inputs [\#295](https://github.com/pcfens/puppet-filebeat/pull/295)
- Add support for Solaris [\#296](https://github.com/pcfens/puppet-filebeat/pull/296)
- Add support for filestreams [\#297](https://github.com/pcfens/puppet-filebeat/pull/297)

## [v4.11.0](https://github.com/pcfens/puppet-filebeat/tree/v4.11.0)
[Full Changelog](https://github.com/pcfens/puppet-filebeat/compare/v4.10.0...v4.11.0)
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ Installs and configures filebeat.
- `setup`: [Hash] Setup that will be created. Commonly used to create setup using hiera
- `xpack`: [Hash] XPack configuration to pass to filebeat
- `extra_validate_options`: [String] Extra command line options to pass to the configuration validation command.
- `overwrite_pipelines`: [Boolean] If set to true, filebeat will overwrite existing pipelines.

### Private Classes

Expand Down Expand Up @@ -399,6 +400,10 @@ to fully understand what these parameters do.
[See above](#multiline-logs). (default: {})
- `host`: [String] Host and port used to read events for TCP or UDP plugin (default: localhost:9000)
- `max_message_size`: [String] The maximum size of the message received over TCP or UDP (default: undef)
- `keep_null`: [Boolean] If this option is set to true, fields with null values will be published in the output document (default: undef)
- `include_matches`: [Array] Journald input only, A collection of filter expressions used to match fields. The format of the expression is field=value (default: [])
- `seek`: [Enum] Journald input only, The position to start reading the journal from (default: undef)
- `index`: [String] If present, this formatted string overrides the index for events from this input (for elasticsearch outputs), or sets the raw_index field of the event’s metadata (for other outputs) (default: undef)

## Limitations
This module doesn't load the [elasticsearch index template](https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-getting-started.html#filebeat-template) into elasticsearch (required when shipping
Expand Down
7 changes: 6 additions & 1 deletion lib/facter/filebeat_version.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'facter'
Facter.add('filebeat_version') do
confine 'kernel' => ['FreeBSD', 'OpenBSD', 'Linux', 'Windows']
confine 'kernel' => ['FreeBSD', 'OpenBSD', 'Linux', 'Windows', 'SunOS']
if File.executable?('/usr/bin/filebeat')
filebeat_version = Facter::Util::Resolution.exec('/usr/bin/filebeat version')
if filebeat_version.empty?
Expand All @@ -11,6 +11,11 @@
if filebeat_version.empty?
filebeat_version = Facter::Util::Resolution.exec('/usr/local/bin/filebeat --version')
end
elsif File.executable?('/opt/local/bin/filebeat')
filebeat_version = Facter::Util::Resolution.exec('/opt/local/bin/filebeat version')
if filebeat_version.empty?
filebeat_version = Facter::Util::Resolution.exec('/opt/local/bin/filebeat --version')
end
elsif File.executable?('/usr/share/filebeat/bin/filebeat')
filebeat_version = Facter::Util::Resolution.exec('/usr/share/filebeat/bin/filebeat --version')
elsif File.executable?('/usr/local/sbin/filebeat')
Expand Down
52 changes: 42 additions & 10 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,21 @@
'enabled' => $filebeat::enable_conf_modules,
'path' => "${filebeat::modules_dir}/*.yml",
},
'shutdown_timeout' => $filebeat::shutdown_timeout,
'modules' => $filebeat::modules,
'registry' => {
'modules' => $filebeat::modules,
'overwrite_pipelines' => $filebeat::overwrite_pipelines,
'shutdown_timeout' => $filebeat::shutdown_timeout,
'registry' => {
'path' => $filebeat::registry_path,
'file_permissions' => $filebeat::registry_file_permissions,
'flush' => $filebeat::registry_flush,
},
'autodiscover' => $filebeat::autodiscover,
},
'http' => $filebeat::http,
'cloud' => $filebeat::cloud,
'output' => $filebeat::outputs,
'shipper' => $filebeat::shipper,
'logging' => $filebeat::logging,
'autodiscover' => $filebeat::autodiscover,
'runoptions' => $filebeat::run_options,
'processors' => $filebeat::processors,
'monitoring' => $filebeat::monitoring,
Expand All @@ -69,12 +70,13 @@
'fields' => $filebeat::fields,
'fields_under_root' => $filebeat::fields_under_root,
'filebeat' => {
'spool_size' => $filebeat::spool_size,
'idle_timeout' => $filebeat::idle_timeout,
'registry_file' => $filebeat::registry_file,
'publish_async' => $filebeat::publish_async,
'config_dir' => $filebeat::config_dir,
'shutdown_timeout' => $filebeat::shutdown_timeout,
'config_dir' => $filebeat::config_dir,
'idle_timeout' => $filebeat::idle_timeout,
'overwrite_pipelines' => $filebeat::overwrite_pipelines,
'publish_async' => $filebeat::publish_async,
'registry_file' => $filebeat::registry_file,
'shutdown_timeout' => $filebeat::shutdown_timeout,
'spool_size' => $filebeat::spool_size,
},
'output' => $filebeat::outputs,
'shipper' => $filebeat::shipper,
Expand Down Expand Up @@ -135,6 +137,36 @@
}
} # end Linux

'SunOS' : {
$validate_cmd = ($filebeat::disable_config_test or $skip_validation) ? {
true => undef,
default => '/opt/local/bin/filebeat test config -c %',
}

file {'filebeat.yml':
ensure => $filebeat::file_ensure,
path => $filebeat::config_file,
content => template($filebeat::conf_template),
owner => $filebeat::config_file_owner,
group => $filebeat::config_file_group,
mode => $filebeat::config_file_mode,
validate_cmd => $validate_cmd,
notify => Service['filebeat'],
require => File['filebeat-config-dir'],
}

file {'filebeat-config-dir':
ensure => $filebeat::directory_ensure,
path => $filebeat::config_dir,
owner => $filebeat::config_dir_owner,
group => $filebeat::config_dir_group,
mode => $filebeat::config_dir_mode,
recurse => $filebeat::purge_conf_dir,
purge => $filebeat::purge_conf_dir,
force => true,
}
} # end SunOS

'FreeBSD' : {
$validate_cmd = ($filebeat::disable_config_test or $skip_validation) ? {
true => undef,
Expand Down
6 changes: 5 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
# @param max_procs [Integer] The maximum number of CPUs that can be simultaneously used
# @param fields [Hash] Optional fields that should be added to each event output
# @param fields_under_root [Boolean] If set to true, custom fields are stored in the top level instead of under fields
# @param ssl [Hash] Optional fields set the ssl-configuration for input
# @param processors [Array] Processors that will be added. Commonly used to create processors using hiera.
# @param monitoring [Hash] The monitoring section of the configuration file.
# @param inputs [Hash] or [Array] Inputs that will be created. Commonly used to create inputs using hiera
Expand All @@ -52,12 +53,13 @@
# @param xpack [Hash] Configuration items to export internal stats to a monitoring Elasticsearch cluster
# @param extra_validate_options [String] Extra command line options to pass to the configuration validation command
# @param autodiscover [Hash] Will be converted to YAML for the optional autodiscover section of the configuration (see documentation, and above)
# @param overwrite_pipelines [Boolean] If set to true filebeat will overwrite (ingest) pipeline in Elasticsearch
class filebeat (
String $package_ensure = $filebeat::params::package_ensure,
Boolean $manage_package = $filebeat::params::manage_package,
Boolean $manage_repo = $filebeat::params::manage_repo,
Boolean $manage_apt = $filebeat::params::manage_apt,
Enum['5','6', '7'] $major_version = $filebeat::params::major_version,
Enum['5','6', '7', '8'] $major_version = $filebeat::params::major_version,
Variant[Boolean, Enum['stopped', 'running']] $service_ensure = $filebeat::params::service_ensure,
Boolean $service_enable = $filebeat::params::service_enable,
Optional[String] $service_provider = $filebeat::params::service_provider,
Expand Down Expand Up @@ -92,6 +94,7 @@
Optional[Integer] $max_procs = $filebeat::params::max_procs,
Hash $fields = $filebeat::params::fields,
Boolean $fields_under_root = $filebeat::params::fields_under_root,
Hash $ssl = $filebeat::params::ssl,
Boolean $disable_config_test = $filebeat::params::disable_config_test,
Array $processors = [],
Optional[Hash] $monitoring = undef,
Expand All @@ -113,6 +116,7 @@
Optional[String] $registry_path = $filebeat::params::registry_path,
Optional[String] $registry_file_permissions = $filebeat::params::registry_file_permissions,
Optional[String] $registry_flush = $filebeat::params::registry_flush,
Boolean $overwrite_pipelines = $filebeat::params::overwrite_pipelines,

) inherits filebeat::params {

Expand Down
40 changes: 32 additions & 8 deletions manifests/input.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
String $syslog_host = 'localhost:5140',
Boolean $cri_parse_flags = false,
String $encoding = 'plain',
String $input_type = 'log',
String $input_type = $filebeat::params::default_input_type,
Hash $fields = {},
Boolean $fields_under_root = $filebeat::fields_under_root,
Hash $ssl = {},
Optional[String] $ignore_older = undef,
Optional[String] $close_older = undef,
String $doc_type = 'log',
Expand Down Expand Up @@ -50,20 +51,25 @@
Array $processors = [],
Boolean $pure_array = false,
String $host = 'localhost:9000',
Boolean $keep_null = false,
Array[String] $include_matches = [],
Optional[Enum['head', 'tail', 'cursor']] $seek = undef,
Optional[String] $max_message_size = undef,
Optional[String] $index = undef,
) {

$input_template = $filebeat::major_version ? {
'5' => 'prospector.yml.erb',
default => 'input.yml.erb',
}

if 'filebeat_version' in $facts and $facts['filebeat_version'] != false {
if versioncmp($facts['filebeat_version'], '6') > 0 {
$input_template = 'input.yml.erb'
} else {
$input_template = 'prospector.yml.erb'
}

$skip_validation = versioncmp($facts['filebeat_version'], $filebeat::major_version) ? {
-1 => true,
default => false,
}
} else {
$input_template = 'input.yml.erb'
$skip_validation = false
}

Expand All @@ -89,11 +95,29 @@
}
}

'SunOS' : {
$validate_cmd = ($filebeat::disable_config_test or $skip_validation) ? {
true => undef,
default => "\"${filebeat::filebeat_path}\" -c \"${filebeat::config_file}\" test config",
}
file { "filebeat-${name}":
ensure => $ensure,
path => "${filebeat::config_dir}/${name}.yml",
owner => 'root',
group => 'root',
mode => $::filebeat::config_file_mode,
content => template("${module_name}/${input_template}"),
validate_cmd => $validate_cmd,
notify => Service['filebeat'],
require => File['filebeat.yml'],
}
}

'FreeBSD' : {
$validate_cmd = ($filebeat::disable_config_test or $skip_validation) ? {
true => undef,
default => $filebeat::major_version ? {
'5' => "/usr/local/sbin/filebeat -N -configtest -c %",
'5' => '/usr/local/sbin/filebeat -N -configtest -c %',
default => "/usr/local/sbin/filebeat -c ${filebeat::config_file} test config",
},
}
Expand Down
6 changes: 6 additions & 0 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
Class['filebeat::repo'] -> Class['filebeat::install::linux']
}
}
'SunOS': {
class{ '::filebeat::install::sunos':
notify => Class['filebeat::service'],
}
Anchor['filebeat::install::begin'] -> Class['filebeat::install::sunos'] -> Anchor['filebeat::install::end']
}
'FreeBSD': {
class{ '::filebeat::install::freebsd':
notify => Class['filebeat::service'],
Expand Down
6 changes: 6 additions & 0 deletions manifests/install/sunos.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# to manage filebeat installation on SunOS
class filebeat::install::sunos {
package {'beats':
ensure => $filebeat::package_ensure,
}
}
32 changes: 30 additions & 2 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
$enable_conf_modules = false
$fields = {}
$fields_under_root = false
$ssl = {}
$http = {}
$cloud = {}
$outputs = {}
Expand All @@ -28,6 +29,7 @@
$autodiscover = {}
$run_options = {}
$modules = []
$overwrite_pipelines = false
$kernel_fail_message = "${::kernel} is not supported by filebeat."
$osfamily_fail_message = "${::osfamily} is not supported by filebeat."
$conf_template = "${module_name}/pure_hash.yml.erb"
Expand Down Expand Up @@ -71,7 +73,7 @@
$manage_repo = true
$manage_apt = true
$filebeat_path = '/usr/share/filebeat/bin/filebeat'
$major_version = '7'
$major_version = '8'
}
}
case $::kernel {
Expand All @@ -89,7 +91,7 @@
$install_dir = undef
case $::osfamily {
'RedHat': {
$service_provider = 'redhat'
$service_provider = 'systemd'
}
default: {
$service_provider = undef
Expand All @@ -98,6 +100,21 @@
$url_arch = undef
}

'SunOS': {
$package_ensure = present
$config_file = '/opt/local/etc/beats/filebeat.yml'
$config_dir = '/opt/local/etc/filebeat.d'
$config_file_owner = 'root'
$config_file_group = 'root'
$config_dir_owner = 'root'
$config_dir_group = 'root'
$modules_dir = '/opt/local/etc/filebeat.modules.d'
$tmp_dir = '/tmp'
$service_provider = undef
$install_dir = undef
$url_arch = undef
}

'FreeBSD': {
$package_ensure = present
$config_file = '/usr/local/etc/beats/filebeat.yml'
Expand Down Expand Up @@ -151,4 +168,15 @@
fail($kernel_fail_message)
}
}

if 'filebeat_version' in $facts and $facts['filebeat_version'] != false {
# filestream input type added in 7.10, deprecated in 7.16
if versioncmp($facts['filebeat_version'], '7.10') > 0 {
$default_input_type = 'filestream'
} else {
$default_input_type = 'log'
}
} else {
$default_input_type = 'filestream'
}
}
2 changes: 1 addition & 1 deletion manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#make sure puppet client version 6.1+ with filebeat version 7+, running on systemd
if ( versioncmp( $major_version, '7' ) >= 0 and
$::service_provider == 'systemd' ) {
$filebeat::service_provider == 'systemd' ) {

if ( versioncmp( $::clientversion, '6.1' ) >= 0 ) {

Expand Down
Loading