-
Notifications
You must be signed in to change notification settings - Fork 178
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
d311ade
commit 0d126ec
Showing
2 changed files
with
85 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,31 @@ | ||
# filebeat::module::rabbitmq | ||
# | ||
# @summary | ||
# This class manages the Filebeat RabbitMQ module. | ||
# | ||
# @example | ||
# class { 'filebeat::module::rabbitmq': | ||
# log_enabled => true, | ||
# log_paths => ['/var/log/rabbitmq/*.log'], | ||
# } | ||
# | ||
# @param log_enabled | ||
# Whether to enable the RabbitMQ module. | ||
# @param log_paths | ||
# An array of paths to the RabbitMQ log files. | ||
# | ||
class filebeat::module::rabbitmq ( | ||
Boolean $log_enabled = false, | ||
Optional[Array[Stdlib::Absolutepath]] $log_paths = undef, | ||
) { | ||
filebeat::module { 'rabbitmq': | ||
config => { | ||
'log' => delete_undef_values( | ||
{ | ||
'enabled' => $log_enabled, | ||
'var.paths' => $log_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,54 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
describe 'filebeat::module::rabbitmq' 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-rabbitmq').with_content( | ||
%r{- module: rabbitmq\n\s{2}log:\n\s{4}enabled: false\n\n}, | ||
)} | ||
end | ||
|
||
context 'on log enabled with paths' do | ||
let(:params) do | ||
{ | ||
'log_enabled' => true, | ||
'log_paths' => ['/var/log/rabbitmq.log'], | ||
} | ||
end | ||
|
||
it { is_expected.to compile.with_all_deps } | ||
|
||
it { | ||
is_expected.to contain_file('filebeat-module-rabbitmq').with_content( | ||
<<-EOS | ||
### Filebeat configuration managed by Puppet ### | ||
--- | ||
- module: rabbitmq | ||
log: | ||
enabled: true | ||
var.paths: | ||
- "/var/log/rabbitmq.log" | ||
EOS | ||
) | ||
} | ||
end | ||
end |