Commit 718f807d authored by Markus Frosch's avatar Markus Frosch 📣
Browse files

ido_mysql: Refactor class

parent 4ce975fa
......@@ -5,7 +5,6 @@ class icinga2_testing::helpers::icinga2::ido_mysql(
) inherits ::icinga2::feature::ido_mysql
{
# Install schema
# TODO: schema upgrades
if $::osfamily == 'Debian' {
$_schema_create = '/usr/share/dbconfig-common/data/icinga2-ido-mysql/install/mysql'
}
......@@ -18,36 +17,42 @@ class icinga2_testing::helpers::icinga2::ido_mysql(
$_mysql = "mysql -B -u '${ido_username}' '${ido_dbname}'"
Package['icinga2-ido-mysql'] ->
exec { 'import icinga2 mysql schema':
user => 'root',
path => $::path,
command => "${_mysql} < '${_schema_create}'",
unless => "${_mysql} --execute='SELECT version FROM icinga_dbversion;'",
path => '/sbin:/usr/sbin:/bin:/usr/bin',
environment => [
"MYSQL_PWD=${ido_password}",
],
}
Package['icinga2-ido-mysql'] -> Exec['import icinga2 mysql schema'] ~> Class['::icinga2::service']
} ~> Class['::icinga2::service']
file { 'icinga2-schema-upgrade':
ensure => file,
owner => 'root',
group => 'root',
mode => '0755',
path => '/usr/local/bin/icinga2-schema-upgrade',
content => file('icinga2_testing/icinga2-schema-upgrade'),
} ->
unless defined(File['icinga2-schema-upgrade']) {
file { 'icinga2-schema-upgrade':
ensure => file,
owner => 'root',
group => 'root',
mode => '0755',
path => '/usr/local/bin/icinga2-schema-upgrade',
content => file('icinga2_testing/icinga2-schema-upgrade'),
}
}
exec { 'icinga2-schema-upgrade':
exec { 'icinga2-schema-upgrade-mysql':
path => $::path,
environment => [
"IDO_DATABASE=$ido_dbname",
"IDO_USERNAME=$ido_username",
"IDO_PASSWORD=$ido_password",
"IDO_DATABASE=${ido_dbname}",
"IDO_USERNAME=${ido_username}",
"IDO_PASSWORD=${ido_password}",
],
logoutput => true,
command => '/usr/local/bin/icinga2-schema-upgrade',
onlyif => '/usr/local/bin/icinga2-schema-upgrade --check',
require => Exec['import icinga2 mysql schema'],
} ~> Class['::icinga2::service']
notify => Class['::icinga2::service'],
require => [
Exec['import icinga2 mysql schema'],
File['icinga2-schema-upgrade'],
],
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment