Skip to content

Commit

Permalink
Install the mariadb client on webservers that monitor the db
Browse files Browse the repository at this point in the history
  • Loading branch information
daaang committed Mar 15, 2024
1 parent 2f8dc63 commit ccdfac8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
7 changes: 7 additions & 0 deletions manifests/profile/prometheus/exporter/webserver/base.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
# BSD License. See LICENSE.txt for details.

class nebula::profile::prometheus::exporter::webserver::base (
Hash[String, Hash[String, String]] $mariadb_connect = {},
Hash[String, Array[String]] $nfs_mounts = {},
Hash[String, Array[String]] $solr_instances = {},
Hash[String, Boolean] $check_shibd = {},
String $target,
) {
include stdlib
$target_mariadb = pick_default($mariadb_connect[$target], {})
$target_nfs = pick_default($nfs_mounts[$target], [])
$target_solr = pick_default($solr_instances[$target], [])
$target_shibd = pick_default($check_shibd[$target], false)
Expand All @@ -21,4 +24,8 @@
file { "/usr/local/lib/prom_web_exporter":
ensure => "directory",
}

if $target_mariadb != {} {
package { "mariadb-client": }
}
}
14 changes: 14 additions & 0 deletions spec/classes/profile/prometheus/exporter/webserver/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,27 @@ def have_script
end

it { is_expected.to compile }
it { is_expected.not_to contain_package("mariadb-client") }
it { is_expected.to contain_file("/usr/local/lib/prom_web_exporter").with_ensure("directory") }
it { is_expected.to have_script.with_mode("0755") }
it { is_expected.to have_script.with_content(/^#!\/usr\/bin\/env bash$/) }
it { is_expected.to have_script.with_content(/^NFS_MOUNTS=\(\)$/) }
it { is_expected.to have_script.with_content(/^SOLR_INSTANCES=\(\)$/) }
it { is_expected.to have_script.with_content(/^ENABLE_SHIBD_CHECK="false"$/) }

context "with mariadb credentials set" do
let(:params) do
super().merge({ mariadb_connect: { "abcd" => {
"hostname" => "abcd-db-host",
"database" => "abcd-database",
"username" => "abcd-db-monitor",
"password" => "random-password",
}}})
end

it { is_expected.to contain_package("mariadb-client") }
end

context "with nfs mounts set" do
let(:params) do
super().merge({ nfs_mounts: { "abcd" => %w[/abc /def /ghi] } })
Expand Down

0 comments on commit ccdfac8

Please sign in to comment.