Skip to content

Commit

Permalink
Merge pull request #391 from Icinga/fix/icingadb-settings
Browse files Browse the repository at this point in the history
Add missing icingadb module settings
  • Loading branch information
lbetz authored Nov 21, 2023
2 parents 3ab382f + cdab8e7 commit 42b30f6
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 3 deletions.
8 changes: 8 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1754,6 +1754,7 @@ The following parameters are available in the `icingaweb2::module::icingadb` cla
* [`redis_tls_cert_file`](#-icingaweb2--module--icingadb--redis_tls_cert_file)
* [`redis_tls_key_file`](#-icingaweb2--module--icingadb--redis_tls_key_file)
* [`redis_tls_cacert_file`](#-icingaweb2--module--icingadb--redis_tls_cacert_file)
* [`settings`](#-icingaweb2--module--icingadb--settings)
* [`commandtransports`](#-icingaweb2--module--icingadb--commandtransports)

##### <a name="-icingaweb2--module--icingadb--ensure"></a>`ensure`
Expand Down Expand Up @@ -2032,6 +2033,13 @@ Location of the CA certificate. Only valid if redis_use_tls is enabled.

Default value: `undef`

##### <a name="-icingaweb2--module--icingadb--settings"></a>`settings`

Data type: `Hash[String, Any]`

General configuration of module icingadb.
See official Icinga [documentation](https://icinga.com/docs/icinga-web/latest/modules/monitoring/doc/03-Configuration)

##### <a name="-icingaweb2--module--icingadb--commandtransports"></a>`commandtransports`

Data type: `Hash[String, Hash]`
Expand Down
1 change: 1 addition & 0 deletions data/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ icingaweb2::module::monitoring::settings: {}
icingaweb2::module::monitoring::commandtransports: {}

icingaweb2::module::icingadb::ensure: present
icingaweb2::module::icingadb::settings: {}
icingaweb2::module::icingadb::commandtransports: {}
icingaweb2::module::icingadb::redis_host: localhost
icingaweb2::module::icingadb::db_resource_name: icingadb
Expand Down
12 changes: 11 additions & 1 deletion manifests/module/icingadb.pp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@
# @param redis_tls_cacert_file
# Location of the CA certificate. Only valid if redis_use_tls is enabled.
#
# @param settings
# General configuration of module icingadb.
# See official Icinga [documentation](https://icinga.com/docs/icinga-web/latest/modules/monitoring/doc/03-Configuration)
#
# @param commandtransports
# A hash of command transports.
#
Expand All @@ -123,6 +127,7 @@
String $package_name,
Stdlib::Host $redis_host,
Hash[String, Hash] $commandtransports,
Hash[String, Any] $settings,
Enum['mysql', 'pgsql'] $db_type,
String $db_resource_name,
Stdlib::Host $db_host,
Expand Down Expand Up @@ -195,7 +200,7 @@
$redis_settings = {}
}

$settings = {
$_settings = {
'icingaweb2-module-icingadb-config' => {
'section_name' => 'icingadb',
'target' => "${module_conf_dir}/config.ini",
Expand Down Expand Up @@ -226,6 +231,11 @@
password => $redis_secondary_password,
}),
},
'icingaweb2-module-icingadb-settings' => {
'section_name' => 'settings',
'target' => "${module_conf_dir}/config.ini",
'settings' => delete_undef_values($settings),
},
}

class { 'icingaweb2::module::icingadb::install': }
Expand Down
2 changes: 1 addition & 1 deletion manifests/module/icingadb/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
noverify => icingaweb2::pick($icingaweb2::module::icingadb::db_tls_noverify, $icingaweb2::config::tls['noverify']),
cipher => icingaweb2::pick($icingaweb2::module::icingadb::db_tls_cipher, $icingaweb2::config::tls['cipher']),
}
$settings = $icingaweb2::module::icingadb::settings
$settings = $icingaweb2::module::icingadb::_settings
$commandtransports = $icingaweb2::module::icingadb::commandtransports

icingaweb2::resource::database { $db_resource:
Expand Down
19 changes: 18 additions & 1 deletion spec/classes/modules/icingadb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
facts
end

context "#{os} with local MySQL and Redis" do
context "#{os} with some settings, local MySQL and Redis" do
let(:pre_condition) do
[
"class { 'icingaweb2': db_type => 'mysql' }",
Expand All @@ -16,6 +16,9 @@

let(:params) do
{
settings: {
'foo' => 'bar',
},
db_type: 'mysql',
db_password: 'secret',
}
Expand Down Expand Up @@ -56,6 +59,13 @@
.with_settings({})
}

it {
is_expected.to contain_icingaweb2__inisection('icingaweb2-module-icingadb-settings')
.with_section_name('settings')
.with_target('/etc/icingaweb2/modules/icingadb/config.ini')
.with_settings({ 'foo' => 'bar' })
}

it {
is_expected.to contain_icingaweb2__resource__database('icingadb').with(
{
Expand Down Expand Up @@ -120,6 +130,13 @@
.with_settings({ 'host' => 'redis2.icinga.com', 'port' => 4712, 'password' => 'secret2' })
}

it {
is_expected.to contain_icingaweb2__inisection('icingaweb2-module-icingadb-settings')
.with_section_name('settings')
.with_target('/etc/icingaweb2/modules/icingadb/config.ini')
.with_settings({})
}

it {
is_expected.to contain_icingaweb2__resource__database('foobaz').with(
{
Expand Down

0 comments on commit 42b30f6

Please sign in to comment.