4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ Style/BlockDelimiters:
Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to
be consistent then.
EnforcedStyle: braces_for_chaining
Style/BracesAroundHashParameters:
Description: Braces are required by Ruby 2.7. Cop removed from RuboCop v0.80.0.
See https://github.com/rubocop-hq/rubocop/pull/7643
Enabled: true
Style/ClassAndModuleChildren:
Description: Compact style reduces the required amount of indentation.
EnforcedStyle: compact
Expand Down
2 changes: 1 addition & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"recommendations": [
"jpogran.puppet-vscode",
"puppet.puppet-vscode",
"rebornix.Ruby"
]
}
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ Changelog
=========

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

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

- Add the ability to supply the monitoring.* of the config file [\#252](https://github.com/pcfens/puppet-filebeat/issues/252)
- Add support for Windows Server 2016 and 2019 Core editions [\#255](https://github.com/pcfens/puppet-filebeat/pull/255)

## [v4.3.1](https://github.com/pcfens/puppet-filebeat/tree/v4.3.1)
[Full Changelog](https://github.com/pcfens/puppet-filebeat/compare/v4.3.0...v4.3.1)
Expand Down
55 changes: 32 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,41 +158,49 @@ processors using hiera), or as their own defined resources.
To drop the offset and input_type fields from all events:

```puppet
class{"filebeat":
processors => {
"drop_fields" => {
"fields" => ["input_type", "offset"],
},
},
class {'filebeat':
processors => [
{
'drop_fields' => {
'fields' => ['input_type', 'offset'],
}
}
],
}
```

To drop all events that have the http response code equal to 200:
input
```puppet
class{"filebeat":
processors => {
"drop_event" => {
"when" => {"equals" => {"http.code" => 200}}
},
},
class {'filebeat':
processors => [
{
'drop_event' => {
'when' => {'equals' => {'http.code' => 200}}
}
}
],
}
```

Now to combine these examples into a single definition:

```puppet
class{"filebeat":
processors => {
"drop_fields" => {
"params" => {"fields" => ["input_type", "offset"]},
"priority" => 1,
},
"drop_event" => {
"when" => {"equals" => {"http.code" => 200}},
"priority: => 2,
class {'filebeat':
processors => [
{
'drop_fields' => {
'params' => {'fields' => ['input_type', 'offset']},
'priority' => 1,
}
},
},
{
'drop_event' => {
'when' => {'equals' => {'http.code' => 200}},
'priority' => 2,
}
}
],
}
```

Expand Down Expand Up @@ -285,7 +293,8 @@ Installs and configures filebeat.
- `fields`: [Hash] Optional fields that should be added to each event output
- `fields_under_root`: [Boolean] If set to true, custom fields are stored in the top level instead of under fields
- `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.
- `processors`: [Array] Processors that should be configured.
- `monitoring`: [Hash] The monitoring.* components of the filebeat configuration.
- `inputs`: [Hash] or [Array] Inputs that will be created. Commonly used to create inputs using hiera
- `setup`: [Hash] Setup that will be created. Commonly used to create setup using hiera
- `xpack`: [Hash] XPack configuration to pass to filebeat
Expand Down
1 change: 1 addition & 0 deletions manifests/config.pp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
'logging' => $filebeat::logging,
'runoptions' => $filebeat::run_options,
'processors' => $filebeat::processors,
'monitoring' => $filebeat::monitoring,
'setup' => $setup,
})
# Add the 'xpack' section if supported (version >= 6.1.0) and not undef
Expand Down
4 changes: 4 additions & 0 deletions manifests/init.pp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
# @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 [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
# @param setup [Hash] setup that will be created. Commonly used to create setup using hiera
# @param inputs_merge [Boolean] Whether $inputs should merge all hiera sources, or use simple automatic parameter lookup
Expand Down Expand Up @@ -87,6 +88,7 @@
Boolean $fields_under_root = $filebeat::params::fields_under_root,
Boolean $disable_config_test = $filebeat::params::disable_config_test,
Array $processors = [],
Hash $monitoring = {},
Variant[Hash, Array] $inputs = {},
Hash $setup = {},
Array $modules = [],
Expand Down Expand Up @@ -119,11 +121,13 @@
$real_service_ensure = 'stopped'
$file_ensure = 'absent'
$directory_ensure = 'absent'
$real_service_enable = false
} else {
$alternate_ensure = 'present'
$file_ensure = 'file'
$directory_ensure = 'directory'
$real_service_ensure = $service_ensure
$real_service_enable = $service_enable
}

# If we're removing filebeat, do things in a different order to make sure
Expand Down
Empty file modified manifests/input.pp
100755 → 100644
Empty file.
14 changes: 13 additions & 1 deletion manifests/install/windows.pp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,20 @@
proxy_server => $filebeat::proxy_address,
}

# Core editions of Windows Server do not have a shell as such, so use the Shell.Application COM object doesn't work.
# Expand-Archive is a native powershell cmdlet which ships with Powershell 5, which in turn ships with Windows 10 and
# Windows Server 2016 and newer.
if ((versioncmp($::operatingsystemrelease, '2016') > 0) or (versioncmp($::operatingsystemrelease, '10') == 0))
{
$unzip_command = "Expand-Archive ${zip_file} \"${filebeat::install_dir}\""
}
else
{
$unzip_command = "\$sh=New-Object -COM Shell.Application;\$sh.namespace((Convert-Path '${filebeat::install_dir}')).Copyhere(\$sh.namespace((Convert-Path '${zip_file}')).items(), 16)" # lint:ignore:140chars
}

exec { "unzip ${filename}":
command => "\$sh=New-Object -COM Shell.Application;\$sh.namespace((Convert-Path '${filebeat::install_dir}')).Copyhere(\$sh.namespace((Convert-Path '${zip_file}')).items(), 16)", # lint:ignore:140chars
command => $unzip_command,
creates => $version_file,
require => [
File[$filebeat::install_dir],
Expand Down
2 changes: 1 addition & 1 deletion manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class filebeat::service {
service { 'filebeat':
ensure => $filebeat::real_service_ensure,
enable => $filebeat::service_enable,
enable => $filebeat::real_service_enable,
provider => $filebeat::service_provider,
}

Expand Down
15 changes: 9 additions & 6 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pcfens-filebeat",
"version": "4.3.1",
"version": "4.4.0",
"author": "pcfens",
"summary": "A module to install and manage the filebeat log shipper",
"license": "Apache-2.0",
Expand Down Expand Up @@ -80,14 +80,17 @@
"operatingsystemrelease": [
"14.04",
"16.04",
"18.04"
"18.04",
"20.04"
]
},
{
"operatingsystem": "windows",
"operatingsystemrelease": [
"2012",
"2012 R2"
"2012 R2",
"2016",
"2019"
]
},
{
Expand All @@ -106,7 +109,7 @@
"elasticsearch",
"elastic"
],
"pdk-version": "1.17.0",
"template-url": "pdk-default#1.17.0",
"template-ref": "tags/1.17.0-0-gd3a4319"
"pdk-version": "1.18.0",
"template-url": "pdk-default#1.18.0",
"template-ref": "tags/1.18.0-0-g095317c"
}
Empty file modified spec/classes/install/windows_spec.rb
100755 → 100644
Empty file.
Empty file modified spec/default_facts.yml
100755 → 100644
Empty file.
1 change: 1 addition & 0 deletions spec/spec_helper.rb
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
# set to strictest setting for testing
# by default Puppet runs at warning level
Puppet.settings[:strict] = :warning
Puppet.settings[:strict_variables] = true
end
c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT']
c.after(:suite) do
Expand Down