Puppet Class: icingaweb2::module::idoreports
- Defined in:
- manifests/module/idoreports.pp
Summary
Installs, configures and enables the idoreports module. The module is deprecated.Overview
Note:
If you want to use ‘git` as `install_method`, the CLI `git` command has to be installed. You can manage it yourself as package resource or declare the package name in icingaweb2 class parameter `extra_packages`.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'manifests/module/idoreports.pp', line 34
class icingaweb2::module::idoreports (
Enum['absent', 'present'] $ensure,
Enum['git', 'none', 'package'] $install_method,
Stdlib::HTTPUrl $git_repository,
String[1] $package_name,
Stdlib::Absolutepath $module_dir = "${icingaweb2::globals::default_module_path}/idoreports",
Optional[Icingaweb2::ImportSchema] $import_schema = undef,
Optional[String[1]] $git_revision = undef,
) {
unless defined(Class['icingaweb2::module::monitoring']) {
fail('You must declare the icingaweb2::module::monitoring class before using icingaweb2::module::idoreports!')
}
require icingaweb2
$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'],
provider => shell,
user => 'root',
require => Class['icingaweb2::module::monitoring'],
}
icingaweb2::module { 'idoreports':
ensure => $ensure,
git_repository => $git_repository,
git_revision => $git_revision,
install_method => $install_method,
module_dir => $module_dir,
package_name => $package_name,
settings => {
'module-idoreports-config' => {
target => "${module_conf_dir}/config.ini",
},
},
}
if $import_schema {
$db = $icingaweb2::module::monitoring::db
$use_tls = $icingaweb2::module::monitoring::use_tls
$tls = $icingaweb2::module::monitoring::config::tls
# determine the real dbms, because there are some differnces between
# the mysql and mariadb client
$real_db_type = if $import_schema =~ Boolean {
if $db['type'] == 'pgsql' { 'pgsql' } else { 'mariadb' }
} else {
$import_schema
}
$db_cli_options = icinga::db::connect($db + { type => $real_db_type }, $tls, $use_tls)
case $db['type'] {
'mysql': {
exec { 'import 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} < '${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 = unwrap($db['pass'])
exec { 'import slaperiods':
environment => ["PGPASSWORD=${_db_password}"],
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 ${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",
}
}
default: {
fail('The database type you provided is not supported.')
}
}
}
}
|