-
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
b6e4773
commit 3107a22
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::mysql | ||
# | ||
# @summary | ||
# This class manages the Filebeat module for MySQL. | ||
# | ||
# @example | ||
# class { 'filebeat::module::mysql': | ||
# error_enabled => true, | ||
# error_paths => [ | ||
# '/var/log/mysql/error.log', | ||
# ], | ||
# slowlog_enabled => true, | ||
# slowlog_paths => [ | ||
# '/var/log/mysql/slow.log', | ||
# ], | ||
# } | ||
# | ||
# @param error_enabled | ||
# Whether to enable the MySQL error log module. Defaults to false. | ||
# @param error_paths | ||
# An array of absolute paths to the MySQL error log files. Defaults to undef. | ||
# @param slowlog_enabled | ||
# Whether to enable the MySQL slow log module. Defaults to false. | ||
# @param slowlog_paths | ||
# An array of absolute paths to the MySQL slow log files. Defaults to undef. | ||
# | ||
class filebeat::module::mysql ( | ||
Boolean $error_enabled = false, | ||
Optional[Array[Stdlib::Absolutepath]] $error_paths = undef, | ||
Boolean $slowlog_enabled = false, | ||
Optional[Array[Stdlib::Absolutepath]] $slowlog_paths = undef, | ||
) { | ||
filebeat::module { 'mysql': | ||
config => { | ||
'error' => delete_undef_values( | ||
{ | ||
'enabled' => $error_enabled, | ||
'var.paths' => $error_paths, | ||
} | ||
), | ||
'slowlog' => delete_undef_values( | ||
{ | ||
'enabled' => $slowlog_enabled, | ||
'var.paths' => $slowlog_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::mysql' 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-mysql').with_content( | ||
%r{- module: mysql\n\s{2}error:\n\s{4}enabled: false\n\s{2}slowlog:\n\s{4}enabled: false\n\n}, | ||
)} | ||
end | ||
|
||
context 'on error and slowlog enabled with paths' do | ||
let(:params) do | ||
{ | ||
'error_enabled' => true, | ||
'error_paths' => ['/var/log/mysql/error.log'], | ||
'slowlog_enabled' => true, | ||
'slowlog_paths' => ['/var/log/mysql/slowlog.log'], | ||
} | ||
end | ||
|
||
it { is_expected.to compile.with_all_deps } | ||
|
||
it { | ||
is_expected.to contain_file('filebeat-module-mysql').with_content( | ||
<<-EOS | ||
### Filebeat configuration managed by Puppet ### | ||
--- | ||
- module: mysql | ||
error: | ||
enabled: true | ||
var.paths: | ||
- "/var/log/mysql/error.log" | ||
slowlog: | ||
enabled: true | ||
var.paths: | ||
- "/var/log/mysql/slowlog.log" | ||
EOS | ||
) | ||
} | ||
end | ||
end |