Skip to content

Commit

Permalink
fix db schema path idoreports
Browse files Browse the repository at this point in the history
  • Loading branch information
lbetz committed Nov 13, 2023
1 parent ed1751f commit ad5c16e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 88 deletions.
74 changes: 0 additions & 74 deletions 3

This file was deleted.

4 changes: 0 additions & 4 deletions data/Linux-kernel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ icingaweb2::globals::data_dir: /usr/share/icingaweb2
icingaweb2::globals::comp_db_schema_dir: /usr/share/doc/icingaweb2
icingaweb2::globals::mysql_db_schema: /usr/share/doc/icingaweb2/schema/mysql.schema.sql
icingaweb2::globals::pgsql_db_schema: /usr/share/doc/icingaweb2/schema/pgsql.schema.sql
icingaweb2::globals::mysql_idoreports_slaperiods: /usr/share/icingaweb2/modules/idoreports/schema/mysql/slaperiods.sql
icingaweb2::globals::mysql_idoreports_sla_percent: /usr/share/icingaweb2/modules/idoreports/schema/mysql/get_sla_ok_percent.sql
icingaweb2::globals::pgsql_idoreports_slaperiods: /usr/share/icingaweb2/modules/idoreports/schema/postgresql/slaperiods.sql
icingaweb2::globals::pgsql_idoreports_sla_percent: /usr/share/icingaweb2/modules/idoreports/schema/postgresql/get_sla_ok_percent.sql
icingaweb2::globals::gettext_package_name: gettext
icingaweb2::globals::icingacli_bin: /usr/bin/icingacli
icingaweb2::globals::default_module_path: /usr/share/icingaweb2/modules
Expand Down
4 changes: 4 additions & 0 deletions data/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ icingaweb2::module::reporting::db_host: localhost
icingaweb2::module::reporting::db_name: reporting
icingaweb2::module::reporting::db_username: reporting

icingaweb2::globals::mysql_idoreports_slaperiods: /schema/mysql/slaperiods.sql
icingaweb2::globals::mysql_idoreports_sla_percent: /schema/mysql/get_sla_ok_percent.sql
icingaweb2::globals::pgsql_idoreports_slaperiods: /schema/postgresql/slaperiods.sql
icingaweb2::globals::pgsql_idoreports_sla_percent: /schema/postgresql/get_sla_ok_percent.sql
icingaweb2::module::idoreports::ensure: present
icingaweb2::module::idoreports::install_method: git
icingaweb2::module::idoreports::git_repository: https://github.com/Icinga/icingaweb2-module-idoreports.git
Expand Down
8 changes: 4 additions & 4 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
$group_backends = $icingaweb2::group_backends

$import_schema = $icingaweb2::import_schema
$mysql_db_schema = $icingaweb2::globals::mysql_db_schema
$pgsql_db_schema = $icingaweb2::globals::pgsql_db_schema
$mysql_schema = $icingaweb2::globals::mysql_db_schema
$pgsql_schema = $icingaweb2::globals::pgsql_db_schema
$db = $icingaweb2::db

$default_domain = $icingaweb2::default_domain
Expand Down Expand Up @@ -180,7 +180,7 @@
case $db['type'] {
'mysql': {
exec { 'import schema':
command => "mysql ${db_cli_options} < '${mysql_db_schema}'",
command => "mysql ${db_cli_options} < '${mysql_schema}'",
unless => "mysql ${db_cli_options} -Ns -e 'SELECT 1 FROM icingaweb_user'",
notify => Exec['create default admin user'],
}
Expand All @@ -194,7 +194,7 @@
$_db_password = icingaweb2::unwrap($db['pass'])
exec { 'import schema':
environment => ["PGPASSWORD=${_db_password}"],
command => "psql '${db_cli_options}' -w -f ${pgsql_db_schema}",
command => "psql '${db_cli_options}' -w -f ${pgsql_schema}",
unless => "psql '${db_cli_options}' -w -c 'SELECT 1 FROM icingaweb_user'",
notify => Exec['create default admin user'],
}
Expand Down
16 changes: 10 additions & 6 deletions manifests/module/idoreports.pp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,12 @@
fail('You must declare the icingaweb2::module::monitoring class before using icingaweb2::module::idoreports!')
}

$conf_dir = $icingaweb2::globals::conf_dir
$module_conf_dir = "${conf_dir}/modules/idoreports"
$conf_dir = $icingaweb2::globals::conf_dir
$module_conf_dir = "${conf_dir}/modules/idoreports"
$mysql_slaperiods = "${icingaweb2::module::idoreports::module_dir}${icingaweb2::globals::mysql_idoreports_slaperiods}"
$mysql_sla_percent = "${icingaweb2::module::idoreports::module_dir}${icingaweb2::globals::mysql_idoreports_sla_percent}"
$pgsql_slaperiods = "${icingaweb2::module::idoreports::module_dir}${icingaweb2::globals::pgsql_idoreports_slaperiods}"
$pgsql_sla_percent = "${icingaweb2::module::idoreports::module_dir}${icingaweb2::globals::pgsql_idoreports_sla_percent}"

Exec {
path => $facts['path'],
Expand Down Expand Up @@ -85,24 +89,24 @@
case $db['type'] {
'mysql': {
exec { 'import slaperiods':
command => "mysql ${db_cli_options} < '${icingaweb2::globals::mysql_idoreports_slaperiods}'",
command => "mysql ${db_cli_options} < '${mysql_slaperiods}'",
unless => "mysql ${db_cli_options} -Ns -e 'SELECT 1 FROM icinga_sla_periods'",
}
exec { 'import get_sla_ok_percent':
command => "mysql ${db_cli_options} < '${icingaweb2::globals::mysql_idoreports_sla_percent}'",
command => "mysql ${db_cli_options} < '${mysql_sla_percent}'",
unless => "if [ \"X$(mysql ${db_cli_options} -Ns -e 'SELECT 1 FROM information_schema.routines WHERE routine_name=\"idoreports_get_sla_ok_percent\"')\" != \"X1\" ];then exit 1; fi",
}
}
'pgsql': {
$_db_password = icingaweb2::unwrap($db['pass'])
exec { 'import slaperiods':
environment => ["PGPASSWORD=${_db_password}"],
command => "psql '${db_cli_options}' -w -f ${icingaweb2::globals::pgsql_idoreports_slaperiods}",
command => "psql '${db_cli_options}' -w -f ${pgsql_slaperiods}",
unless => "psql '${db_cli_options}' -w -c 'SELECT 1 FROM icinga_outofsla_periods'",
}
exec { 'import get_sla_ok_percent':
environment => ["PGPASSWORD=${_db_password}"],
command => "psql '${db_cli_options}' -w -f ${icingaweb2::globals::pgsql_idoreports_sla_percent}",
command => "psql '${db_cli_options}' -w -f ${pgsql_sla_percent}",
unless => "if [ \"X$(psql '${db_cli_options}' -w -t -c \"SELECT 1 FROM information_schema.routines WHERE routine_name='idoreports_get_sla_ok_percent'\"|xargs)\" != \"X1\" ];then exit 1; fi",
}
}
Expand Down

0 comments on commit ad5c16e

Please sign in to comment.