Skip to content

Commit

Permalink
Set schema directory depending on kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
bobapple authored and n00by committed Apr 26, 2018
1 parent 1c0f23e commit e676ed7
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 49 deletions.
19 changes: 10 additions & 9 deletions manifests/feature/idomysql.pp
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,15 @@
require ::icinga2::config
require ::icinga2::params

$owner = $::icinga2::params::user
$group = $::icinga2::params::group
$node_name = $::icinga2::_constants['NodeName']
$conf_dir = $::icinga2::params::conf_dir
$ssl_dir = "${::icinga2::params::pki_dir}/ido-mysql"
$ido_mysql_package = $::icinga2::params::ido_mysql_package
$manage_package = $::icinga2::manage_package
$_ssl_key_mode = $::osfamily ? {
$owner = $::icinga2::params::user
$group = $::icinga2::params::group
$node_name = $::icinga2::_constants['NodeName']
$conf_dir = $::icinga2::params::conf_dir
$ssl_dir = "${::icinga2::params::pki_dir}/ido-mysql"
$ido_mysql_package = $::icinga2::params::ido_mysql_package
$ido_mysql_schema_dir = $::icinga2::params::ido_mysql_schema_dir
$manage_package = $::icinga2::manage_package
$_ssl_key_mode = $::osfamily ? {
'windows' => undef,
default => '0600',
}
Expand Down Expand Up @@ -328,7 +329,7 @@
exec { 'idomysql-import-schema':
user => 'root',
path => $::path,
command => "mysql -h '${host}' -u '${user}' -p'${password}' '${database}' < '/usr/share/icinga2-ido-mysql/schema/mysql.sql'",
command => "mysql -h '${host}' -u '${user}' -p'${password}' '${database}' < '${ido_mysql_schema_dir}/mysql.sql'",
unless => "mysql -h '${host}' -u '${user}' -p'${password}' '${database}' -Ns -e 'select version from icinga_dbversion'",
}
}
Expand Down
11 changes: 6 additions & 5 deletions manifests/feature/idopgsql.pp
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,11 @@
require ::icinga2::config
require ::icinga2::params

$conf_dir = $::icinga2::params::conf_dir
$ido_pgsql_package = $::icinga2::params::ido_pgsql_package
$manage_package = $::icinga2::manage_package
$_notify = $ensure ? {
$conf_dir = $::icinga2::params::conf_dir
$ido_pgsql_package = $::icinga2::params::ido_pgsql_package
$ido_pgsql_schema_dir = $::icinga2::params::ido_pgsql_schema_dir
$manage_package = $::icinga2::manage_package
$_notify = $ensure ? {
'present' => Class['::icinga2::service'],
default => undef,
}
Expand Down Expand Up @@ -146,7 +147,7 @@
user => 'root',
path => $::path,
environment => ["PGPASSWORD=${password}"],
command => "psql -h '${host}' -U '${user}' -d '${database}' -w -f /usr/share/icinga2-ido-pgsql/schema/pgsql.sql",
command => "psql -h '${host}' -U '${user}' -d '${database}' -w -f ${ido_pgsql_schema_dir}/pgsql.sql",
unless => "psql -h '${host}' -U '${user}' -d '${database}' -w -c 'select version from icinga_dbversion'",
}
}
Expand Down
76 changes: 41 additions & 35 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,18 @@
case $::kernel {

'linux': {
$conf_dir = '/etc/icinga2'
$log_dir = '/var/log/icinga2'
$run_dir = '/var/run/icinga2'
$spool_dir = '/var/spool/icinga2'
$cache_dir = '/var/cache/icinga2'
$pki_dir = "${conf_dir}/pki"
$ca_dir = '/var/lib/icinga2/ca'
$ido_pgsql_package = 'icinga2-ido-pgsql'
$ido_mysql_package = 'icinga2-ido-mysql'
$service_reload = "service ${service} reload"
$conf_dir = '/etc/icinga2'
$log_dir = '/var/log/icinga2'
$run_dir = '/var/run/icinga2'
$spool_dir = '/var/spool/icinga2'
$cache_dir = '/var/cache/icinga2'
$pki_dir = "${conf_dir}/pki"
$ca_dir = '/var/lib/icinga2/ca'
$ido_pgsql_package = 'icinga2-ido-pgsql'
$ido_pgsql_schema_dir = '/usr/share/icinga2-ido-pgsql/schema'
$ido_mysql_package = 'icinga2-ido-mysql'
$ido_mysql_schema_dir = '/usr/share/icinga2-ido-mysql/schema'
$service_reload = "service ${service} reload"

case $::osfamily {
'redhat': {
Expand Down Expand Up @@ -135,18 +137,20 @@
} # Linux

'windows': {
$user = 'SYSTEM'
$group = undef
$conf_dir = 'C:/ProgramData/icinga2/etc/icinga2'
$log_dir = 'C:/ProgramData/icinga2/var/log/icinga2'
$run_dir = 'C:/ProgramData/icinga2/var/run/icinga2'
$spool_dir = 'C:/ProgramData/icinga2/var/spool/icinga2'
$cache_dir = 'C:/ProgramData/icinga2/var/cache/icinga2'
$pki_dir = "${conf_dir}/pki"
$ca_dir = 'C:/ProgramData/icinga2/var/lib/icinga2/ca'
$ido_pgsql_package = undef
$ido_mysql_package = undef
$service_reload = undef
$user = 'SYSTEM'
$group = undef
$conf_dir = 'C:/ProgramData/icinga2/etc/icinga2'
$log_dir = 'C:/ProgramData/icinga2/var/log/icinga2'
$run_dir = 'C:/ProgramData/icinga2/var/run/icinga2'
$spool_dir = 'C:/ProgramData/icinga2/var/spool/icinga2'
$cache_dir = 'C:/ProgramData/icinga2/var/cache/icinga2'
$pki_dir = "${conf_dir}/pki"
$ca_dir = 'C:/ProgramData/icinga2/var/lib/icinga2/ca'
$ido_pgsql_package = undef
$ido_pgsql_schema_dir = undef
$ido_mysql_package = undef
$ido_mysql_schema_dir = undef
$service_reload = undef

$constants = {
'PluginDir' => 'C:/Program Files/ICINGA2/sbin',
Expand All @@ -159,19 +163,21 @@
} # Windows

'FreeBSD': {
$conf_dir = '/usr/local/etc/icinga2'
$log_dir = '/var/log/icinga2'
$run_dir = '/var/run/icinga2'
$spool_dir = '/var/spool/icinga2'
$cache_dir = '/var/cache/icinga2'
$pki_dir = "${conf_dir}/pki"
$ca_dir = '/var/lib/icinga2/ca'
$user = 'icinga'
$group = 'icinga'
$lib_dir = '/usr/local/lib/icinga2'
$ido_pgsql_package = undef
$ido_mysql_package = undef
$service_reload = "service ${service} reload"
$conf_dir = '/usr/local/etc/icinga2'
$log_dir = '/var/log/icinga2'
$run_dir = '/var/run/icinga2'
$spool_dir = '/var/spool/icinga2'
$cache_dir = '/var/cache/icinga2'
$pki_dir = "${conf_dir}/pki"
$ca_dir = '/var/lib/icinga2/ca'
$user = 'icinga'
$group = 'icinga'
$lib_dir = '/usr/local/lib/icinga2'
$ido_pgsql_package = undef
$ido_pgsql_schema_dir = '/usr/local/share/icinga2-ido-pgsql/schema'
$ido_mysql_package = undef
$ido_mysql_schema_dir = '/usr/local/share/icinga2-ido-mysql/schema'
$service_reload = "service ${service} reload"

$constants = {
'PluginDir' => '/usr/local/libexec/nagios',
Expand Down

0 comments on commit e676ed7

Please sign in to comment.