Commit 2d9d272c authored by Markus Frosch's avatar Markus Frosch 📣

ido_pgsql: Add for parallel database setup

parent 718f807d
class icinga2_testing::helpers::icinga2::ido_pgsql(
$ido_dbname = $::icinga2::feature::ido_pgsql::database,
$ido_username = $::icinga2::feature::ido_pgsql::user,
$ido_password = $::icinga2::feature::ido_pgsql::password,
) inherits ::icinga2::feature::ido_pgsql
{
# Install schema
if $::osfamily == 'Debian' {
$_schema_create = '/usr/share/dbconfig-common/data/icinga2-ido-pgsql/install/pgsql'
}
elsif $::osfamily == 'Redhat' {
$_schema_create = '/usr/share/icinga2-ido-pgsql/schema/pgsql.sql'
}
else {
fail("Schema creating not supported on ${::operatingsystem} (${::osfamily})")
}
$_psql = "psql -U '${ido_username}' -h '${host}' -d '${ido_dbname}'"
Package['icinga2-ido-pgsql'] ->
exec { 'import icinga2 pgsql schema':
user => 'root',
path => $::path,
command => "${_psql} < '${_schema_create}'",
unless => "${_psql} -c 'SELECT version FROM icinga_dbversion'",
environment => [
"PGPASSWORD=${ido_password}",
],
} ~> Class['::icinga2::service']
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-pgsql':
path => $::path,
environment => [
"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',
notify => Class['::icinga2::service'],
require => [
Exec['import icinga2 pgsql 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