Skip to content

Commit

Permalink
add parameter to name the database resources
Browse files Browse the repository at this point in the history
  • Loading branch information
lbetz committed Nov 18, 2023
1 parent a132a72 commit f4463f3
Show file tree
Hide file tree
Showing 23 changed files with 232 additions and 57 deletions.
49 changes: 49 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ The following parameters are available in the `icingaweb2` class:
* [`extra_packages`](#-icingaweb2--extra_packages)
* [`import_schema`](#-icingaweb2--import_schema)
* [`db_type`](#-icingaweb2--db_type)
* [`db_resource_name`](#-icingaweb2--db_resource_name)
* [`db_host`](#-icingaweb2--db_host)
* [`db_port`](#-icingaweb2--db_port)
* [`db_name`](#-icingaweb2--db_name)
Expand Down Expand Up @@ -326,6 +327,12 @@ Data type: `Enum['mysql', 'pgsql']`

Database type, can be either `mysql` or `pgsql`.

##### <a name="-icingaweb2--db_resource_name"></a>`db_resource_name`

Data type: `String`

Name for the icingaweb2 database resource.

##### <a name="-icingaweb2--db_host"></a>`db_host`

Data type: `Stdlib::Host`
Expand Down Expand Up @@ -963,6 +970,7 @@ The following parameters are available in the `icingaweb2::module::director` cla
* [`install_method`](#-icingaweb2--module--director--install_method)
* [`package_name`](#-icingaweb2--module--director--package_name)
* [`db_type`](#-icingaweb2--module--director--db_type)
* [`db_resource_name`](#-icingaweb2--module--director--db_resource_name)
* [`db_host`](#-icingaweb2--module--director--db_host)
* [`db_port`](#-icingaweb2--module--director--db_port)
* [`db_name`](#-icingaweb2--module--director--db_name)
Expand Down Expand Up @@ -1037,6 +1045,12 @@ Data type: `Enum['mysql', 'pgsql']`

Type of your database. Either `mysql` or `pgsql`.

##### <a name="-icingaweb2--module--director--db_resource_name"></a>`db_resource_name`

Data type: `String`

Name for the director database resource.

##### <a name="-icingaweb2--module--director--db_host"></a>`db_host`

Data type: `Stdlib::Host`
Expand Down Expand Up @@ -1694,6 +1708,7 @@ The following parameters are available in the `icingaweb2::module::icingadb` cla
* [`ensure`](#-icingaweb2--module--icingadb--ensure)
* [`package_name`](#-icingaweb2--module--icingadb--package_name)
* [`db_type`](#-icingaweb2--module--icingadb--db_type)
* [`db_resource_name`](#-icingaweb2--module--icingadb--db_resource_name)
* [`db_host`](#-icingaweb2--module--icingadb--db_host)
* [`db_port`](#-icingaweb2--module--icingadb--db_port)
* [`db_name`](#-icingaweb2--module--icingadb--db_name)
Expand Down Expand Up @@ -1746,6 +1761,12 @@ Data type: `Enum['mysql', 'pgsql']`

Type of your IDO database. Either `mysql` or `pgsql`.

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

Data type: `String`

Name for the icingadb database resource.

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

Data type: `Stdlib::Host`
Expand Down Expand Up @@ -2120,6 +2141,7 @@ The following parameters are available in the `icingaweb2::module::monitoring` c
* [`ido_type`](#-icingaweb2--module--monitoring--ido_type)
* [`ido_host`](#-icingaweb2--module--monitoring--ido_host)
* [`ido_port`](#-icingaweb2--module--monitoring--ido_port)
* [`ido_resource_name`](#-icingaweb2--module--monitoring--ido_resource_name)
* [`ido_db_name`](#-icingaweb2--module--monitoring--ido_db_name)
* [`ido_db_username`](#-icingaweb2--module--monitoring--ido_db_username)
* [`ido_db_password`](#-icingaweb2--module--monitoring--ido_db_password)
Expand Down Expand Up @@ -2169,6 +2191,12 @@ Port of the IDO database.

Default value: `undef`

##### <a name="-icingaweb2--module--monitoring--ido_resource_name"></a>`ido_resource_name`

Data type: `String`

Resource name for the IDO database.

##### <a name="-icingaweb2--module--monitoring--ido_db_name"></a>`ido_db_name`

Data type: `String`
Expand Down Expand Up @@ -2532,6 +2560,7 @@ The following parameters are available in the `icingaweb2::module::reporting` cl
* [`install_method`](#-icingaweb2--module--reporting--install_method)
* [`package_name`](#-icingaweb2--module--reporting--package_name)
* [`db_type`](#-icingaweb2--module--reporting--db_type)
* [`db_resource_name`](#-icingaweb2--module--reporting--db_resource_name)
* [`db_host`](#-icingaweb2--module--reporting--db_host)
* [`db_port`](#-icingaweb2--module--reporting--db_port)
* [`db_name`](#-icingaweb2--module--reporting--db_name)
Expand Down Expand Up @@ -2601,6 +2630,12 @@ Data type: `Enum['mysql', 'pgsql']`

The database type. Either mysql or postgres.

##### <a name="-icingaweb2--module--reporting--db_resource_name"></a>`db_resource_name`

Data type: `String`

Name for the reporting database resource.

##### <a name="-icingaweb2--module--reporting--db_host"></a>`db_host`

Data type: `Stdlib::Host`
Expand Down Expand Up @@ -2811,6 +2846,7 @@ The following parameters are available in the `icingaweb2::module::vspheredb` cl
* [`install_method`](#-icingaweb2--module--vspheredb--install_method)
* [`package_name`](#-icingaweb2--module--vspheredb--package_name)
* [`db_type`](#-icingaweb2--module--vspheredb--db_type)
* [`db_resource_name`](#-icingaweb2--module--vspheredb--db_resource_name)
* [`db_host`](#-icingaweb2--module--vspheredb--db_host)
* [`db_port`](#-icingaweb2--module--vspheredb--db_port)
* [`db_name`](#-icingaweb2--module--vspheredb--db_name)
Expand Down Expand Up @@ -2879,6 +2915,12 @@ Data type: `Enum['mysql']`

The database type. Either mysql or postgres.

##### <a name="-icingaweb2--module--vspheredb--db_resource_name"></a>`db_resource_name`

Data type: `String`

Name for the vspheredb database resource.

##### <a name="-icingaweb2--module--vspheredb--db_host"></a>`db_host`

Data type: `Stdlib::Host`
Expand Down Expand Up @@ -3065,6 +3107,7 @@ The following parameters are available in the `icingaweb2::module::x509` class:
* [`install_method`](#-icingaweb2--module--x509--install_method)
* [`package_name`](#-icingaweb2--module--x509--package_name)
* [`db_type`](#-icingaweb2--module--x509--db_type)
* [`db_resource_name`](#-icingaweb2--module--x509--db_resource_name)
* [`db_host`](#-icingaweb2--module--x509--db_host)
* [`db_port`](#-icingaweb2--module--x509--db_port)
* [`db_name`](#-icingaweb2--module--x509--db_name)
Expand Down Expand Up @@ -3133,6 +3176,12 @@ Data type: `Enum['mysql', 'pgsql']`

The database type. Either mysql or pgsql.

##### <a name="-icingaweb2--module--x509--db_resource_name"></a>`db_resource_name`

Data type: `String`

Name for the x509 database resource.

##### <a name="-icingaweb2--module--x509--db_host"></a>`db_host`

Data type: `Stdlib::Host`
Expand Down
7 changes: 7 additions & 0 deletions data/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ icingaweb2::theme_disabled: false
icingaweb2::manage_repos: false
icingaweb2::manage_package: true
icingaweb2::import_schema: false
icingaweb2::db_resource_name: icingaweb2
icingaweb2::db_host: localhost
icingaweb2::db_name: icingaweb2
icingaweb2::db_username: icingaweb2
Expand All @@ -28,13 +29,15 @@ icingaweb2::module::monitoring::protected_customvars:
- '*pass*'
- 'community'
icingaweb2::module::monitoring::ido_host: localhost
icingaweb2::module::monitoring::ido_resource_name: icinga2
icingaweb2::module::monitoring::ido_db_name: icinga2
icingaweb2::module::monitoring::ido_db_username: icinga2
icingaweb2::module::monitoring::commandtransports: {}

icingaweb2::module::icingadb::ensure: present
icingaweb2::module::icingadb::commandtransports: {}
icingaweb2::module::icingadb::redis_host: localhost
icingaweb2::module::icingadb::db_resource_name: icingadb
icingaweb2::module::icingadb::db_host: localhost
icingaweb2::module::icingadb::db_name: icingadb
icingaweb2::module::icingadb::db_username: icingadb
Expand All @@ -50,6 +53,7 @@ icingaweb2::module::director::manage_service: true
icingaweb2::module::director::service_ensure: running
icingaweb2::module::director::service_enable: true
icingaweb2::module::director::service_user: icingadirector
icingaweb2::module::director::db_resource_name: director
icingaweb2::module::director::db_host: localhost
icingaweb2::module::director::db_name: director
icingaweb2::module::director::db_username: director
Expand All @@ -64,6 +68,7 @@ icingaweb2::module::reporting::service_ensure: running
icingaweb2::module::reporting::service_enable: true
icingaweb2::module::reporting::service_user: icingareporting
icingaweb2::module::reporting::import_schema: false
icingaweb2::module::reporting::db_resource_name: reporting
icingaweb2::module::reporting::db_host: localhost
icingaweb2::module::reporting::db_name: reporting
icingaweb2::module::reporting::db_username: reporting
Expand All @@ -88,6 +93,7 @@ icingaweb2::module::x509::service_ensure: running
icingaweb2::module::x509::service_enable: true
icingaweb2::module::x509::service_user: icingax509
icingaweb2::module::x509::import_schema: false
icingaweb2::module::x509::db_resource_name: x509
icingaweb2::module::x509::db_host: localhost
icingaweb2::module::x509::db_name: x509
icingaweb2::module::x509::db_username: x509
Expand All @@ -102,6 +108,7 @@ icingaweb2::module::vspheredb::service_ensure: running
icingaweb2::module::vspheredb::service_enable: true
icingaweb2::module::vspheredb::service_user: icingavspheredb
icingaweb2::module::vspheredb::import_schema: false
icingaweb2::module::vspheredb::db_resource_name: vspheredb
icingaweb2::module::vspheredb::db_host: localhost
icingaweb2::module::vspheredb::db_name: vspheredb
icingaweb2::module::vspheredb::db_username: vspheredb
Expand Down
10 changes: 5 additions & 5 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
$mysql_schema = $icingaweb2::globals::mysql_db_schema
$pgsql_schema = $icingaweb2::globals::pgsql_db_schema
$db = $icingaweb2::db
$db_resource = $icingaweb2::db_resource_name

$default_domain = $icingaweb2::default_domain
$admin_role = $icingaweb2::admin_role
$admin_username = $icingaweb2::default_admin_username
$admin_password = icingaweb2::unwrap($icingaweb2::default_admin_password)
$config_resource = "${db['type']}-icingaweb2"

$use_tls = $icingaweb2::use_tls
$tls = $icingaweb2::tls + {
Expand Down Expand Up @@ -64,7 +64,7 @@
$settings = {
'show_stacktraces' => $show_stacktraces,
'module_path' => join(unique([$default_module_path] + $module_path), ':'),
'config_resource' => $config_resource,
'config_resource' => $db_resource,
}

icingaweb2::inisection { 'config-global':
Expand Down Expand Up @@ -133,7 +133,7 @@
}
}

icingaweb2::resource::database { "${db['type']}-icingaweb2":
icingaweb2::resource::database { $db_resource:
type => $db['type'],
host => $db['host'],
port => $db['port'],
Expand All @@ -151,12 +151,12 @@

icingaweb2::config::groupbackend { "${db['type']}-group":
backend => 'db',
resource => "${db['type']}-icingaweb2",
resource => $db_resource,
}

icingaweb2::config::authmethod { "${db['type']}-auth":
backend => 'db',
resource => "${db['type']}-icingaweb2",
resource => $db_resource,
}

if $import_schema {
Expand Down
4 changes: 4 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
# @param db_type
# Database type, can be either `mysql` or `pgsql`.
#
# @param db_resource_name
# Name for the icingaweb2 database resource.
#
# @param db_host
# Database hostname.
#
Expand Down Expand Up @@ -226,6 +229,7 @@
Hash[String, Hash[String, Any]] $user_backends,
Hash[String, Hash[String, Any]] $group_backends,
Variant[Boolean, Enum['mariadb', 'mysql']] $import_schema,
String $db_resource_name,
Stdlib::Host $db_host,
String $db_name,
String $db_username,
Expand Down
6 changes: 5 additions & 1 deletion manifests/module/director.pp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
# @param db_type
# Type of your database. Either `mysql` or `pgsql`.
#
# @param db_resource_name
# Name for the director database resource.
#
# @param db_host
# Hostname of the database.
#
Expand Down Expand Up @@ -138,6 +141,7 @@
Boolean $import_schema,
Boolean $kickstart,
Enum['mysql', 'pgsql'] $db_type,
String $db_resource_name,
Stdlib::Host $db_host,
String $db_name,
String $db_username,
Expand Down Expand Up @@ -190,7 +194,7 @@
'section_name' => 'db',
'target' => "${module_conf_dir}/config.ini",
'settings' => {
'resource' => 'icingaweb2-module-director',
'resource' => $db_resource_name,
},
},
}
Expand Down
3 changes: 2 additions & 1 deletion manifests/module/director/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
$icingacli_bin = $icingaweb2::globals::icingacli_bin
$install_method = $icingaweb2::module::director::install_method
$db = $icingaweb2::module::director::db
$db_resource = $icingaweb2::module::director::db_resource_name
$import_schema = $icingaweb2::module::director::import_schema
$kickstart = $icingaweb2::module::director::kickstart
$use_tls = $icingaweb2::module::director::use_tls
Expand All @@ -28,7 +29,7 @@
provider => 'shell',
}

icingaweb2::resource::database { 'icingaweb2-module-director':
icingaweb2::resource::database { $db_resource:
type => $db['type'],
host => $db['host'],
port => $db['port'],
Expand Down
8 changes: 6 additions & 2 deletions manifests/module/icingadb.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
# @param db_type
# Type of your IDO database. Either `mysql` or `pgsql`.
#
# @param db_resource_name
# Name for the icingadb database resource.
#
# @param db_host
# Hostname of the IcingaDB database.
#
Expand Down Expand Up @@ -120,8 +123,9 @@
String $package_name,
Stdlib::Host $redis_host,
Hash[String, Hash] $commandtransports,
Stdlib::Host $db_host,
Enum['mysql', 'pgsql'] $db_type,
String $db_resource_name,
Stdlib::Host $db_host,
String $db_name,
String $db_username,
Optional[Stdlib::Port] $db_port = undef,
Expand Down Expand Up @@ -196,7 +200,7 @@
'section_name' => 'icingadb',
'target' => "${module_conf_dir}/config.ini",
'settings' => {
resource => 'icingaweb2-module-icingadb',
resource => $db_resource_name,
},
},
'icingaweb2-module-icingadb-redis' => {
Expand Down
3 changes: 2 additions & 1 deletion manifests/module/icingadb/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
$ensure = $icingaweb2::module::icingadb::ensure
$module_conf_dir = "${icingaweb2::globals::conf_dir}/modules/icingadb"
$db_type = $icingaweb2::module::icingadb::db_type
$db_resource = $icingaweb2::module::icingadb::db_resource_name
$db_host = $icingaweb2::module::icingadb::db_host
$db_port = $icingaweb2::module::icingadb::db_port
$db_name = $icingaweb2::module::icingadb::db_name
Expand All @@ -25,7 +26,7 @@
$settings = $icingaweb2::module::icingadb::settings
$commandtransports = $icingaweb2::module::icingadb::commandtransports

icingaweb2::resource::database { 'icingaweb2-module-icingadb':
icingaweb2::resource::database { $db_resource:
type => $db_type,
host => $db_host,
port => $db_port,
Expand Down
6 changes: 5 additions & 1 deletion manifests/module/monitoring.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
# @param ido_port
# Port of the IDO database.
#
# @param ido_resource_name
# Resource name for the IDO database.
#
# @param ido_db_name
# Name of the IDO database.
#
Expand Down Expand Up @@ -93,6 +96,7 @@
Hash $commandtransports,
Enum['mysql', 'pgsql'] $ido_type,
Stdlib::Host $ido_host,
String $ido_resource_name,
String $ido_db_name,
String $ido_db_username,
Optional[Stdlib::Port] $ido_port = undef,
Expand Down Expand Up @@ -136,7 +140,7 @@

$backend_settings = {
'type' => 'ido',
'resource' => 'icingaweb2-module-monitoring',
'resource' => $ido_resource_name,
}

$security_settings = {
Expand Down
Loading

0 comments on commit f4463f3

Please sign in to comment.