Puppet Class: icingaweb2::module::idoreports
- Defined in:
- manifests/module/idoreports.pp
Summary
Installs, configures and enables the idoreports module.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`.
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 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'manifests/module/idoreports.pp', line 81
class icingaweb2::module::idoreports (
Enum['absent', 'present'] $ensure,
Enum['git', 'none', 'package'] $install_method,
String $git_repository,
String $package_name,
Optional[Stdlib::Absolutepath] $module_dir = undef,
Optional[String] $git_revision = undef,
Variant[Boolean, Enum['mariadb', 'mysql']] $import_schema = false,
Optional[String] $ido_db_username = $icingaweb2::module::monitoring::ido_db_username,
Optional[Icingaweb2::Secret] $ido_db_password = $icingaweb2::module::monitoring::ido_db_password,
Optional[Boolean] $use_tls = $icingaweb2::module::monitoring::use_tls,
Optional[Stdlib::Absolutepath] $tls_key_file = $icingaweb2::module::monitoring::tls_key_file,
Optional[Stdlib::Absolutepath] $tls_cert_file = $icingaweb2::module::monitoring::tls_cert_file,
Optional[Stdlib::Absolutepath] $tls_cacert_file = $icingaweb2::module::monitoring::tls_cacert_file,
Optional[Stdlib::Absolutepath] $tls_capath = $icingaweb2::module::monitoring::tls_capath,
Optional[Icingaweb2::Secret] $tls_key = $icingaweb2::module::monitoring::tls_key,
Optional[String] $tls_cert = $icingaweb2::module::monitoring::tls_cert,
Optional[String] $tls_cacert = $icingaweb2::module::monitoring::tls_cacert,
Optional[Boolean] $tls_noverify = $icingaweb2::module::monitoring::tls_noverify,
Optional[String] $tls_cipher = $icingaweb2::module::monitoring::tls_cipher,
) {
unless defined(Class['icingaweb2::module::monitoring']) {
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"
Exec {
path => $facts['path'],
provider => shell,
user => 'root',
require => Icingaweb2::Module['idoreports'],
}
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 = {
type => $icingaweb2::module::monitoring::ido_type,
host => $icingaweb2::module::monitoring::ido_host,
port => pick($icingaweb2::module::monitoring::ido_port, $icingaweb2::globals::port[$icingaweb2::module::monitoring::ido_type]),
name => $icingaweb2::module::monitoring::ido_db_name,
user => $ido_db_username,
pass => $ido_db_password,
}
$tls = merge(delete($icingaweb2::config::tls, ['key', 'cert', 'cacert']), delete_undef_values(merge(icingaweb2::cert::files(
'client',
$module_conf_dir,
$tls_key_file,
$tls_cert_file,
$tls_cacert_file,
$tls_key,
$tls_cert,
$tls_cacert,
), {
capath => $tls_capath,
noverify => $tls_noverify,
cipher => $tls_cipher,
})))
icingaweb2::tls::client { 'icingaweb2::module::idoreports tls client config':
args => $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 = icingaweb2::db::connect($db + { type => $real_db_type }, $tls, $use_tls)
case $db['type'] {
'mysql': {
exec { 'import slaperiods':
command => "mysql ${db_cli_options} < '${icingaweb2::globals::mysql_idoreports_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}'",
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}",
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}",
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.')
}
}
}
}
|