-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d867220
commit b687806
Showing
2 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# filebeat::module::system | ||
# | ||
# @summary | ||
# This class manages the Filebeat system module. | ||
# | ||
# @example | ||
# class { 'filebeat::module::system': | ||
# syslog_enabled => true, | ||
# syslog_paths => [ | ||
# '/var/log/syslog', | ||
# ], | ||
# auth_enabled => true, | ||
# auth_paths => [ | ||
# '/var/log/auth.log', | ||
# ], | ||
# } | ||
# | ||
# @param syslog_enabled | ||
# A boolean value to enable or disable the syslog module. | ||
# @param syslog_paths | ||
# An optional array of paths to the syslog logs. | ||
# @param auth_enabled | ||
# A boolean value to enable or disable the auth module. | ||
# @param auth_paths | ||
# An optional array of paths to the auth logs. | ||
# | ||
class filebeat::module::system ( | ||
Boolean $syslog_enabled = false, | ||
Optional[Array[Stdlib::Unixpath]] $syslog_paths = undef, | ||
Boolean $auth_enabled = false, | ||
Optional[Array[Stdlib::Unixpath]] $auth_paths = undef, | ||
) { | ||
filebeat::module { 'system': | ||
config => { | ||
'syslog' => delete_undef_values( | ||
{ | ||
'enabled' => $syslog_enabled, | ||
'var.paths' => $syslog_paths, | ||
} | ||
), | ||
'auth' => delete_undef_values( | ||
{ | ||
'enabled' => $auth_enabled, | ||
'var.paths' => $auth_paths, | ||
} | ||
), | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
describe 'filebeat::module::system' do | ||
let :pre_condition do | ||
'include ::filebeat' | ||
end | ||
|
||
let(:facts) { | ||
{ | ||
:kernel => 'Linux', | ||
:os => { | ||
:family => 'Debian', | ||
:name => 'Ubuntu', | ||
} | ||
} | ||
} | ||
|
||
context 'on default values' do | ||
it { is_expected.to compile.with_all_deps } | ||
|
||
it { | ||
is_expected.to contain_file('filebeat-module-system').with_content( | ||
%r{- module: system\n\s{2}syslog:\n\s{4}enabled: false\n\s{2}auth:\n\s{4}enabled: false\n\n}, | ||
)} | ||
end | ||
|
||
context 'on log and slowlog enabled with paths' do | ||
let(:params) do | ||
{ | ||
'syslog_enabled' => true, | ||
'syslog_paths' => ['/var/log/syslog'], | ||
'auth_enabled' => true, | ||
'auth_paths' => ['/var/log/auth.log'], | ||
} | ||
end | ||
|
||
it { is_expected.to compile.with_all_deps } | ||
|
||
it { | ||
is_expected.to contain_file('filebeat-module-system').with_content( | ||
<<-EOS | ||
### Filebeat configuration managed by Puppet ### | ||
--- | ||
- module: system | ||
syslog: | ||
enabled: true | ||
var.paths: | ||
- "/var/log/syslog" | ||
auth: | ||
enabled: true | ||
var.paths: | ||
- "/var/log/auth.log" | ||
EOS | ||
) | ||
} | ||
end | ||
end |