Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some issues if tls and noverify for mariadb/mysql #96

Merged
merged 1 commit into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ Setting `manage_database` to `true` also setups a database as specified in `db_t

The class supports:

* [puppet] >= 6.0 < 8.0
* [puppet] >= 7.0 < 9.0

And requires:

Expand Down
10 changes: 5 additions & 5 deletions functions/db/connect.pp
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@ function icinga::db::connect(
'mariadb': {
$tls_options = join(any2array(delete_undef_values({
'--ssl' => '',
'--ssl-ca' => $tls['cacert_file'],
'--ssl-ca' => if $tls['noverify'] { undef } else { $tls['cacert_file'] },
'--ssl-cert' => $tls['cert_file'],
'--ssl-key' => $tls['key_file'],
'--ssl-capath' => $tls['capath'],
'--ssl-capath' => if $tls['noverify'] { undef } else { $tls['capath'] },
'--ssl-cipher' => $tls['cipher'],
})), ' ')
}
'mysql': {
$tls_options = join(any2array(delete_undef_values({
'--ssl-mode' => 'required',
'--ssl-ca' => $tls['cacert_file'],
'--ssl-mode' => if $tls['noverify'] { 'REQUIRED' } else { 'VERIFY_CA' },
'--ssl-ca' => if $tls['noverify'] { undef } else { $tls['cacert_file'] },
'--ssl-cert' => $tls['cert_file'],
'--ssl-key' => $tls['key_file'],
'--ssl-capath' => $tls['capath'],
'--ssl-capath' => if $tls['noverify'] { undef } else { $tls['capath'] },
'--ssl-cipher' => $tls['cipher'],
})), ' ')
}
Expand Down
5 changes: 4 additions & 1 deletion manifests/web.pp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
-> Class['apache']
-> Class['icingaweb2']

# version if the used icingaweb2 puppet module
$icingaweb2_version = load_module_metadata('icingaweb2')['version']

#
# Platform
#
Expand Down Expand Up @@ -181,7 +184,7 @@
#
# Icinga Web 2
#
if versioncmp(load_module_metadata('icingaweb2')['version'], '4.0.0') < 0 {
if versioncmp($icingaweb2_version, '4.0.0') < 0 {
class { 'icingaweb2':
db_type => $db_type,
db_host => $_db_host,
Expand Down
16 changes: 12 additions & 4 deletions spec/functions/db_connect_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@
).and_return("-h db.example.org -u bar -p'supersecret' -D foo --ssl --ssl-ca /cacert.file")
end

it "with MariaDB TLS and noverify 'true' on db.example.org and password" do
is_expected.to run.with_params(
{ 'type' => 'mariadb', 'host' => 'db.example.org', 'database' => 'foo', 'username' => 'bar', 'password' => 'supersecret' },
{ 'noverify' => true, 'cacert_file' => '/cacert.file' },
true,
).and_return("-h db.example.org -u bar -p'supersecret' -D foo --ssl")
end

it 'with MariaDB client TLS cert on db.example.org' do
is_expected.to run.with_params(
{ 'type' => 'mariadb', 'host' => 'db.example.org', 'database' => 'foo', 'username' => 'bar' },
Expand All @@ -36,15 +44,15 @@
{ 'type' => 'mysql', 'host' => 'db.example.org', 'database' => 'foo', 'username' => 'bar' },
{ 'key_file' => '/key.file', 'cert_file' => '/cert.file', 'cacert_file' => '/cacert.file' },
true,
).and_return('-h db.example.org -u bar -D foo --ssl-mode required --ssl-ca /cacert.file --ssl-cert /cert.file --ssl-key /key.file')
).and_return('-h db.example.org -u bar -D foo --ssl-mode VERIFY_CA --ssl-ca /cacert.file --ssl-cert /cert.file --ssl-key /key.file')
end

it 'with MySQL TLS on db.example.org and password' do
it "with MySQL TLS and noverify 'true' on db.example.org and password" do
is_expected.to run.with_params(
{ 'type' => 'mysql', 'host' => 'db.example.org', 'database' => 'foo', 'username' => 'bar', 'password' => 'supersecret' },
{ 'cacert_file' => '/cacert.file' },
{ 'noverify' => true, 'cacert_file' => '/cacert.file' },
true,
).and_return("-h db.example.org -u bar -p'supersecret' -D foo --ssl-mode required --ssl-ca /cacert.file")
).and_return("-h db.example.org -u bar -p'supersecret' -D foo --ssl-mode REQUIRED")
end

it 'with PostgreSQL' do
Expand Down
Loading