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
121
122
123
124
|
# File 'manifests/module/vspheredb.pp', line 55
class icingaweb2::module::vspheredb (
Enum['absent', 'present'] $ensure = 'present',
Optional[Stdlib::Absolutepath] $module_dir = undef,
String $git_repository = 'https://github.com/Icinga/icingaweb2-module-vspheredb.git',
Optional[String] $git_revision = undef,
Enum['git', 'none', 'package'] $install_method = 'git',
String $package_name = 'icingaweb2-module-vspheredb',
Enum['mysql'] $db_type = 'mysql',
Optional[Stdlib::Host] $db_host = undef,
Stdlib::Port $db_port = 3306,
Optional[String] $db_name = undef,
Optional[String] $db_username = undef,
Optional[Icingaweb2::Secret] $db_password = undef,
String $db_charset = 'utf8mb4',
Boolean $import_schema = false,
) {
$conf_dir = $::icingaweb2::globals::conf_dir
$mysql_vspheredb_schema = $::icingaweb2::globals::mysql_vspheredb_schema
$module_conf_dir = "${conf_dir}/modules/vspheredb"
icingaweb2::config::resource { 'icingaweb2-module-vspheredb':
type => 'db',
db_type => $db_type,
host => $db_host,
port => $db_port,
db_name => $db_name,
db_username => $db_username,
db_password => $db_password,
db_charset => $db_charset,
}
icingaweb2::module { 'vspheredb':
ensure => $ensure,
git_repository => $git_repository,
git_revision => $git_revision,
install_method => $install_method,
module_dir => $module_dir,
package_name => $package_name,
settings => {
'icingaweb2-module-vspheredb' => {
'section_name' => 'db',
'target' => "${module_conf_dir}/config.ini",
'settings' => {
'resource' => 'icingaweb2-module-vspheredb',
},
},
},
}
if $import_schema {
$_db_password = icingaweb2::unwrap($db_password)
case $db_type {
'mysql': {
exec { 'import vspheredb schema':
user => 'root',
path => $::facts['path'],
command => "mysql -h '${db_host}' -P '${db_port}' -u '${db_username}' -p'${_db_password}' '${db_name}' < '${mysql_vspheredb_schema}'",
unless => "mysql -h '${db_host}' -P '${db_port}' -u '${db_username}' -p'${_db_password}' '${db_name}' -Ns -e 'SELECT schema_version FROM vspheredb_schema_migration'",
require => Icingaweb2::Module['vspheredb'],
}
}
default: {
fail('The database type you provided is not supported.')
}
}
}
}
|