Showing with 578 additions and 350 deletions.
  1. +18 −1 CHANGELOG.md
  2. +2 −1 README.md
  3. +1 −1 lib/facter/filebeat_version.rb
  4. +19 −6 manifests/config.pp
  5. +43 −41 manifests/init.pp
  6. +4 −0 manifests/install/linux.pp
  7. +24 −23 manifests/params.pp
  8. +94 −94 manifests/prospector.pp
  9. +1 −1 manifests/repo.pp
  10. +2 −2 metadata.json
  11. +1 −0 spec/default_facts.yml
  12. +188 −180 templates/prospector.yml.erb
  13. +181 −0 templates/prospector5.yml.erb
19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,24 @@ Changelog
=========

## Unreleased
[Full Changelog](https://github.com/pcfens/puppet-filebeat/compare/v2.4.0...HEAD)
[Full Changelog](https://github.com/pcfens/puppet-filebeat/compare/v3.0.0...HEAD)

## [v3.0.0](https://github.com/pcfens/puppet-filebeat/tree/v3.0.0)
[Full Changelog](https://github.com/pcfens/puppet-filebeat/compare/v2.4.0...v3.0.0)

Potentially Breaking Change:
- Make filebeat 6 the default version.

Non-breaking changes:
- Allow setup entries in configuration [\#152](https://github.com/pcfens/puppet-filebeat/pull/152), [\#146](https://github.com/pcfens/puppet-filebeat/issues/146)
- Processors should be an array of hashes [\#157](https://github.com/pcfens/puppet-filebeat/pull/157), [\#156](https://github.com/pcfens/puppet-filebeat/issues/156)
- Validate URLs using stdlib [\#158](https://github.com/pcfens/puppet-filebeat/pull/158)
- Use external configuration setup for Filebeat 6+ [\#153](https://github.com/pcfens/puppet-filebeat/issues/153)
- Use version subcommand when determining version [\#159](https://github.com/pcfens/puppet-filebeat/issues/159)
- Add processors support to prospectors [\#162](https://github.com/pcfens/puppet-filebeat/pull/162)
- Update unsupported OS Family notice [\#161](https://github.com/pcfens/puppet-filebeat/pull/161)
- Use Puppet 4+ data types for prospectors [\#165](https://github.com/pcfens/puppet-filebeat/pull/165)
- Fix windows validation command [\#164](https://github.com/pcfens/puppet-filebeat/pull/164), [\#163](https://github.com/pcfens/puppet-filebeat/issues/163)

## [v2.4.0](https://github.com/pcfens/puppet-filebeat/tree/v2.4.0)
[Full Changelog](https://github.com/pcfens/puppet-filebeat/compare/v2.3.0...v2.4.0)
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ with required configurations.

### Upgrading to Filebeat 6.x

To upgrade to Filebeat 6.x, simply set `$filebeat::major_version` to `6` and `$filebeat::package_ensure` to `latest`.
To upgrade to Filebeat 6.x, simply set `$filebeat::major_version` to `6` and `$filebeat::package_ensure` to `latest` (or whichever version of 6.x you want, just not present).


### Setup Requirements
Expand Down Expand Up @@ -262,6 +262,7 @@ Installs and configures filebeat.
- `disable_config_test`: [Boolean] If set to true, configuration tests won't be run on config files before writing them.
- `processors`: [Hash] Processors that should be configured.
- `prospectors`: [Hash] Prospectors that will be created. Commonly used to create prospectors using hiera
- `setup`: [Hash] Setup that will be created. Commonly used to create setup using hiera

### Private Classes

Expand Down
2 changes: 1 addition & 1 deletion lib/facter/filebeat_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Facter.add('filebeat_version') do
confine 'kernel' => %w[FreeBSD Linux Windows]
if File.executable?('/usr/bin/filebeat')
filebeat_version = Facter::Util::Resolution.exec('/usr/bin/filebeat --version')
filebeat_version = Facter::Util::Resolution.exec('/usr/bin/filebeat version')
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
25 changes: 19 additions & 6 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,19 @@
'fields' => $filebeat::fields,
'fields_under_root' => $filebeat::fields_under_root,
'filebeat' => {
'registry_file' => $filebeat::registry_file,
'config_dir' => $filebeat::config_dir,
'shutdown_timeout' => $filebeat::shutdown_timeout,
'registry_file' => $filebeat::registry_file,
'config.prospectors' => {
'enabled' => true,
'path' => "${filebeat::config_dir}/*.yml",
},
'shutdown_timeout' => $filebeat::shutdown_timeout,
},
'output' => $filebeat::outputs,
'shipper' => $filebeat::shipper,
'logging' => $filebeat::logging,
'runoptions' => $filebeat::run_options,
'processors' => $filebeat::processors,
'setup' => $filebeat::setup,
})
} else {
$filebeat_config = delete_undef_values({
Expand All @@ -50,11 +54,20 @@
})
}

if $::filebeat_version {
$skip_validation = versioncmp($::filebeat_version, $filebeat::major_version) ? {
-1 => true,
default => false,
}
} else {
$skip_validation = false
}

Filebeat::Prospector <| |> -> File['filebeat.yml']

case $::kernel {
'Linux' : {
$validate_cmd = $filebeat::disable_config_test ? {
$validate_cmd = ($filebeat::disable_config_test or $skip_validation) ? {
true => undef,
default => $major_version ? {
'5' => "${filebeat::filebeat_path} -N -configtest -c %",
Expand Down Expand Up @@ -87,7 +100,7 @@
} # end Linux

'FreeBSD' : {
$validate_cmd = $filebeat::disable_config_test ? {
$validate_cmd = ($filebeat::disable_config_test or $skip_validation) ? {
true => undef,
default => '/usr/local/sbin/filebeat -N -configtest -c %',
}
Expand Down Expand Up @@ -120,7 +133,7 @@
$cmd_install_dir = regsubst($filebeat::install_dir, '/', '\\', 'G')
$filebeat_path = join([$cmd_install_dir, 'Filebeat', 'filebeat.exe'], '\\')

$validate_cmd = $filebeat::disable_config_test ? {
$validate_cmd = ($filebeat::disable_config_test or $skip_validation) ? {
true => undef,
default => "\"${filebeat_path}\" -N -configtest -c \"%\"",
}
Expand Down
84 changes: 43 additions & 41 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -40,51 +40,53 @@
# @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 processors [Hash] Processors that will be added. Commonly used to create processors using hiera.
# @param processors [Array] Processors that will be added. Commonly used to create processors using hiera.
# @param prospectors [Hash] Prospectors that will be created. Commonly used to create prospectors using hiera
# @param setup [Hash] setup that will be created. Commonly used to create setup using hiera
# @param prospectors_merge [Boolean] Whether $prospectors should merge all hiera sources, or use simple automatic parameter lookup
# proxy_address [String] Proxy server to use for downloading files
class filebeat (
String $package_ensure = $filebeat::params::package_ensure,
Boolean $manage_repo = $filebeat::params::manage_repo,
Enum['5','6'] $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,
Optional[Integer] $repo_priority = undef,
Integer $spool_size = $filebeat::params::spool_size,
String $idle_timeout = $filebeat::params::idle_timeout,
Boolean $publish_async = $filebeat::params::publish_async,
String $registry_file = $filebeat::params::registry_file,
String $config_file = $filebeat::params::config_file,
Optional[String] $config_file_owner = $filebeat::params::config_file_owner,
Optional[String] $config_file_group = $filebeat::params::config_file_group,
String[4,4] $config_dir_mode = $filebeat::params::config_dir_mode,
String $config_dir = $filebeat::params::config_dir,
String[4,4] $config_file_mode = $filebeat::params::config_file_mode,
Optional[String] $config_dir_owner = $filebeat::params::config_dir_owner,
Optional[String] $config_dir_group = $filebeat::params::config_dir_group,
Boolean $purge_conf_dir = $filebeat::params::purge_conf_dir,
Hash $outputs = $filebeat::params::outputs,
Hash $shipper = $filebeat::params::shipper,
Hash $logging = $filebeat::params::logging,
Hash $run_options = $filebeat::params::run_options,
String $conf_template = $filebeat::params::conf_template,
Optional[Pattern[/^(http(?:s)?\:\/\/[a-zA-Z0-9]+(?:(?:\.|\-)[a-zA-Z0-9]+)+(?:\:\d+)?(?:\/[\w\-\.]+)*(?:\/?|\/\w+\.[a-zA-Z]{2,4}(?:\?[\w]+\ = [\w\-]+)?)?(?:\&[\w]+\=[\w\-]+)*)$/]] $download_url = undef, # lint:ignore:140chars
Optional[String] $install_dir = $filebeat::params::install_dir,
String $tmp_dir = $filebeat::params::tmp_dir,
Integer $shutdown_timeout = $filebeat::params::shutdown_timeout,
String $beat_name = $filebeat::params::beat_name,
Array $tags = $filebeat::params::tags,
Integer $queue_size = $filebeat::params::queue_size,
Optional[Integer] $max_procs = $filebeat::params::max_procs,
Hash $fields = $filebeat::params::fields,
Boolean $fields_under_root = $filebeat::params::fields_under_root,
Boolean $disable_config_test = $filebeat::params::disable_config_test,
Hash $processors = {},
Hash $prospectors = {},
Optional[Pattern[/^(http(?:s)?\:\/\/[a-zA-Z0-9]+(?:(?:\.|\-)[a-zA-Z0-9]+)+(?:\:\d+)?(?:\/[\w\-\.]+)*(?:\/?|\/\w+\.[a-zA-Z]{2,4}(?:\?[\w]+\ = [\w\-]+)?)?(?:\&[\w]+\=[\w\-]+)*)$/]] $proxy_address = undef, # lint:ignore:140chars
Stdlib::Absolutepath $filebeat_path = $filebeat::params::filebeat_path
String $package_ensure = $filebeat::params::package_ensure,
Boolean $manage_repo = $filebeat::params::manage_repo,
Enum['5','6'] $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,
Optional[Integer] $repo_priority = undef,
Integer $spool_size = $filebeat::params::spool_size,
String $idle_timeout = $filebeat::params::idle_timeout,
Boolean $publish_async = $filebeat::params::publish_async,
String $registry_file = $filebeat::params::registry_file,
String $config_file = $filebeat::params::config_file,
Optional[String] $config_file_owner = $filebeat::params::config_file_owner,
Optional[String] $config_file_group = $filebeat::params::config_file_group,
String[4,4] $config_dir_mode = $filebeat::params::config_dir_mode,
String $config_dir = $filebeat::params::config_dir,
String[4,4] $config_file_mode = $filebeat::params::config_file_mode,
Optional[String] $config_dir_owner = $filebeat::params::config_dir_owner,
Optional[String] $config_dir_group = $filebeat::params::config_dir_group,
Boolean $purge_conf_dir = $filebeat::params::purge_conf_dir,
Hash $outputs = $filebeat::params::outputs,
Hash $shipper = $filebeat::params::shipper,
Hash $logging = $filebeat::params::logging,
Hash $run_options = $filebeat::params::run_options,
String $conf_template = $filebeat::params::conf_template,
Optional[Variant[Stdlib::HTTPUrl, Stdlib::HTTPSUrl]] $download_url = undef, # lint:ignore:140chars
Optional[String] $install_dir = $filebeat::params::install_dir,
String $tmp_dir = $filebeat::params::tmp_dir,
String $shutdown_timeout = $filebeat::params::shutdown_timeout,
String $beat_name = $filebeat::params::beat_name,
Array $tags = $filebeat::params::tags,
Integer $queue_size = $filebeat::params::queue_size,
Optional[Integer] $max_procs = $filebeat::params::max_procs,
Hash $fields = $filebeat::params::fields,
Boolean $fields_under_root = $filebeat::params::fields_under_root,
Boolean $disable_config_test = $filebeat::params::disable_config_test,
Array $processors = [],
Hash $prospectors = {},
Hash $setup = {},
Optional[Variant[Stdlib::HTTPUrl, Stdlib::HTTPSUrl]] $proxy_address = undef, # lint:ignore:140chars
Stdlib::Absolutepath $filebeat_path = $filebeat::params::filebeat_path
) inherits filebeat::params {

include ::stdlib
Expand Down
4 changes: 4 additions & 0 deletions manifests/install/linux.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
# @summary A simple class to install the filebeat package
#
class filebeat::install::linux {
if $::kernel != 'Linux' {
fail('filebeat::install::linux shouldn\'t run on Windows')
}

package {'filebeat':
ensure => $filebeat::package_ensure,
}
Expand Down
47 changes: 24 additions & 23 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,29 @@
#
# @summary Set a bunch of default parameters
class filebeat::params {
$service_ensure = running
$service_enable = true
$spool_size = 2048
$idle_timeout = '5s'
$publish_async = false
$shutdown_timeout = 0
$beat_name = $::fqdn
$tags = []
$queue_size = 1000
$max_procs = undef
$config_file_mode = '0644'
$config_dir_mode = '0755'
$purge_conf_dir = true
$fields = {}
$fields_under_root = false
$outputs = {}
$shipper = {}
$logging = {}
$run_options = {}
$kernel_fail_message = "${::kernel} is not supported by filebeat."
$conf_template = "${module_name}/pure_hash.yml.erb"
$disable_config_test = false
$service_ensure = running
$service_enable = true
$spool_size = 2048
$idle_timeout = '5s'
$publish_async = false
$shutdown_timeout = '0'
$beat_name = $::fqdn
$tags = []
$queue_size = 1000
$max_procs = undef
$config_file_mode = '0644'
$config_dir_mode = '0755'
$purge_conf_dir = true
$fields = {}
$fields_under_root = false
$outputs = {}
$shipper = {}
$logging = {}
$run_options = {}
$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"
$disable_config_test = false

# These are irrelevant as long as the template is set based on the major_version parameter
# if versioncmp('1.9.1', $::rubyversion) > 0 {
Expand All @@ -46,7 +47,7 @@
default: {
$manage_repo = true
$filebeat_path = '/usr/share/filebeat/bin/filebeat'
$major_version = '5'
$major_version = '6'
}
}
case $::kernel {
Expand Down
Loading