Puppet Class: icingaweb2::initialize
- Defined in:
- manifests/initialize.pp
Overview
Class icingaweb2::initialize
This class is used to initialize a default icingaweb2 db and user Depends on the pupppetlabs-mysql module
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 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 |
# File 'manifests/initialize.pp', line 5
class icingaweb2::initialize {
if $::icingaweb2::initialize {
Exec {
path => $::path,
}
case $::operatingsystem {
'RedHat', 'CentOS': {
case $::icingaweb2::web_db {
'mysql': {
if $::icingaweb2::install_method == 'git' {
$sql_schema_location = '/usr/share/icingaweb2/etc/schema/mysql.schema.sql'
} else {
$sql_schema_location = '/usr/share/doc/icingaweb2/schema/mysql.schema.sql'
}
exec { 'create db scheme':
command => "mysql --defaults-file='/root/.my.cnf' ${::icingaweb2::web_db_name} < ${sql_schema_location}",
unless => "mysql --defaults-file='/root/.my.cnf' ${::icingaweb2::web_db_name} -e \"SELECT 1 FROM icingaweb_user LIMIT 1;\"",
notify => Exec['create web user']
}
exec { 'create web user':
command => "mysql --defaults-file='/root/.my.cnf' ${::icingaweb2::web_db_name} -e \" INSERT INTO icingaweb_user (name, active, password_hash) VALUES ('icingaadmin', 1, '\\\$1\\\$EzxLOFDr\\\$giVx3bGhVm4lDUAw6srGX1');\"",
refreshonly => true,
}
}
default: {
fail "DB type ${::icingaweb2::web_db} not supported yet"
}
}
}
'Debian', 'Ubuntu': {
case $::icingaweb2::web_db {
'mysql': {
$sql_schema_location = '/usr/share/icingaweb2/etc/schema/mysql.schema.sql'
exec { 'create db scheme':
command => "mysql -h ${::icingaweb2::web_db_host} -u${::icingaweb2::web_db_user} -p${::icingaweb2::web_db_pass} ${::icingaweb2::web_db_name} < ${sql_schema_location}",
unless => "mysql -h ${::icingaweb2::web_db_host} -u${::icingaweb2::web_db_user} -p${::icingaweb2::web_db_pass} ${::icingaweb2::web_db_name} -e \"SELECT 1 FROM icingaweb_user LIMIT 1;\"",
notify => Exec['create web user']
}
exec { 'create web user':
command => "mysql -h ${::icingaweb2::web_db_host} -u${::icingaweb2::web_db_user} -p${::icingaweb2::web_db_pass} ${::icingaweb2::web_db_name} -e \" INSERT INTO icingaweb_user (name, active, password_hash) VALUES ('icingaadmin', 1, '\\\$1\\\$EzxLOFDr\\\$giVx3bGhVm4lDUAw6srGX1');\"",
refreshonly => true,
}
}
default: {
fail "DB type ${::icingaweb2::web_db} not supported yet"
}
}
}
default: {
fail "Managing repositories for ${::operatingsystem} is not supported."
}
}
}
}
|