diff --git a/manifests/conf.pp b/manifests/conf.pp index 06a6e031..57012731 100644 --- a/manifests/conf.pp +++ b/manifests/conf.pp @@ -23,7 +23,7 @@ $template = undef, $options_hash = undef, $ensure = present, - $target_dir = '/etc/icinga2/conf.d', + $target_dir = "${::icinga2::config_dir}/conf.d", $target_file_name = "${name}.conf", $target_file_owner = $::icinga2::config_owner, $target_file_group = $::icinga2::config_group, diff --git a/manifests/config.pp b/manifests/config.pp index cf40a327..adeff57e 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -14,10 +14,10 @@ # maintained directories file { [ - '/etc/icinga2', - '/etc/icinga2/pki', - '/etc/icinga2/scripts', - '/etc/icinga2/features-available', + $::icinga2::config_dir, + "${::icinga2::config_dir}/pki", + "${::icinga2::config_dir}/scripts", + "${::icinga2::config_dir}/features-available", ]: ensure => directory, } @@ -25,7 +25,7 @@ # TODO: temporary until we provide some default templates file { [ - '/etc/icinga2/conf.d', + "${::icinga2::config_dir}/conf.d", ]: ensure => directory, purge => $::icinga2::purge_confd, @@ -35,9 +35,9 @@ file { [ - '/etc/icinga2/features-enabled', - '/etc/icinga2/objects', - '/etc/icinga2/zones.d', + "${::icinga2::config_dir}/features-enabled", + "${::icinga2::config_dir}/objects", + "${::icinga2::config_dir}/zones.d", ]: ensure => directory, purge => $::icinga2::purge_configs, @@ -45,7 +45,7 @@ force => $::icinga2::purge_configs, } - file { '/etc/icinga2/icinga2.conf': + file { "${::icinga2::config_dir}/icinga2.conf": ensure => file, content => template($::icinga2::config_template), } @@ -53,28 +53,28 @@ # maintained object directories file { [ - '/etc/icinga2/objects/hosts', - '/etc/icinga2/objects/hostgroups', - '/etc/icinga2/objects/services', - '/etc/icinga2/objects/servicegroups', - '/etc/icinga2/objects/users', - '/etc/icinga2/objects/usergroups', - '/etc/icinga2/objects/checkcommands', - '/etc/icinga2/objects/notificationcommands', - '/etc/icinga2/objects/eventcommands', - '/etc/icinga2/objects/notifications', - '/etc/icinga2/objects/timeperiods', - '/etc/icinga2/objects/scheduleddowntimes', - '/etc/icinga2/objects/dependencies', - '/etc/icinga2/objects/perfdatawriters', - '/etc/icinga2/objects/graphitewriters', - '/etc/icinga2/objects/idomysqlconnections', - '/etc/icinga2/objects/idopgsqlconnections', - '/etc/icinga2/objects/livestatuslisteners', - '/etc/icinga2/objects/statusdatawriters', - '/etc/icinga2/objects/applys', - '/etc/icinga2/objects/templates', - '/etc/icinga2/objects/constants', + "${::icinga2::config_dir}/objects/hosts", + "${::icinga2::config_dir}/objects/hostgroups", + "${::icinga2::config_dir}/objects/services", + "${::icinga2::config_dir}/objects/servicegroups", + "${::icinga2::config_dir}/objects/users", + "${::icinga2::config_dir}/objects/usergroups", + "${::icinga2::config_dir}/objects/checkcommands", + "${::icinga2::config_dir}/objects/notificationcommands", + "${::icinga2::config_dir}/objects/eventcommands", + "${::icinga2::config_dir}/objects/notifications", + "${::icinga2::config_dir}/objects/timeperiods", + "${::icinga2::config_dir}/objects/scheduleddowntimes", + "${::icinga2::config_dir}/objects/dependencies", + "${::icinga2::config_dir}/objects/perfdatawriters", + "${::icinga2::config_dir}/objects/graphitewriters", + "${::icinga2::config_dir}/objects/idomysqlconnections", + "${::icinga2::config_dir}/objects/idopgsqlconnections", + "${::icinga2::config_dir}/objects/livestatuslisteners", + "${::icinga2::config_dir}/objects/statusdatawriters", + "${::icinga2::config_dir}/objects/applys", + "${::icinga2::config_dir}/objects/templates", + "${::icinga2::config_dir}/objects/constants", ]: ensure => directory, purge => $::icinga2::purge_configs, @@ -82,7 +82,7 @@ force => $::icinga2::purge_configs, } - file { '/etc/icinga2/zones.conf': + file { "${::icinga2::config_dir}/zones.conf": ensure => file, content => template('icinga2/zones.conf.erb'), } diff --git a/manifests/config/objectdir.pp b/manifests/config/objectdir.pp index 27072622..c25e29d6 100644 --- a/manifests/config/objectdir.pp +++ b/manifests/config/objectdir.pp @@ -17,7 +17,7 @@ Class['icinga2::config'] -> file { "icinga2 objectdir ${name}": ensure => directory, - path => "/etc/icinga2/objects/${name}", + path => "${::icinga2::config_dir}/objects/${name}", owner => $::icinga2::config_owner, group => $::icinga2::config_group, mode => $::icinga2::config_mode, @@ -26,4 +26,4 @@ force => $::icinga2::purge_configs, } -} \ No newline at end of file +} diff --git a/manifests/database.pp b/manifests/database.pp index 69584254..a5460fed 100644 --- a/manifests/database.pp +++ b/manifests/database.pp @@ -26,8 +26,8 @@ exec { 'mysql_schema_load': user => 'root', path => $::path, - command => "mysql -h '${::icinga2::db_host}' -u '${::icinga2::db_user}' -p'${::icinga2::db_pass}' '${::icinga2::db_name}' < '${db_schema}' && touch /etc/icinga2/mysql_schema_loaded.txt", - creates => '/etc/icinga2/mysql_schema_loaded.txt', + command => "mysql -h '${::icinga2::db_host}' -u '${::icinga2::db_user}' -p'${::icinga2::db_pass}' '${::icinga2::db_name}' < '${db_schema}' && touch ${::icinga2::config_dir}/mysql_schema_loaded.txt", + creates => "${::icinga2::config_dir}/mysql_schema_loaded.txt", } } elsif $::icinga2::db_type == 'pgsql' { @@ -47,8 +47,8 @@ environment => [ "PGPASSWORD=${::icinga2::db_pass}", ], - command => "psql -U '${::icinga2::db_user}' -h '${::icinga2::db_host}' ${port} -d '${::icinga2::db_name}' < '${db_schema}' && touch /etc/icinga2/postgres_schema_loaded.txt", - creates => '/etc/icinga2/postgres_schema_loaded.txt', + command => "psql -U '${::icinga2::db_user}' -h '${::icinga2::db_host}' ${port} -d '${::icinga2::db_name}' < '${db_schema}' && touch ${::icinga2::config_dir}/postgres_schema_loaded.txt", + creates => "${::icinga2::config_dir}/postgres_schema_loaded.txt", } } diff --git a/manifests/feature.pp b/manifests/feature.pp index 1b66cbcd..f47524b2 100644 --- a/manifests/feature.pp +++ b/manifests/feature.pp @@ -33,7 +33,7 @@ Class['icinga2::config'] -> file { "icinga2 feature ${name}": ensure => file, - path => "/etc/icinga2/features-available/${name}.conf", + path => "${::icinga2::config_dir}/features-available/${name}.conf", content => $content_rel, } -> File["icinga2 feature ${name} enabled"] @@ -42,8 +42,8 @@ file { "icinga2 feature ${name} enabled": ensure => link, - path => "/etc/icinga2/features-enabled/${name}.conf", - target => "../features-available/${name}.conf", + path => "${::icinga2::config_dir}/features-enabled/${name}.conf", + target => "${::icinga2::config_dir}/features-available/${name}.conf", } if $::icinga2::manage_service { diff --git a/manifests/feature/api.pp b/manifests/feature/api.pp index 643d319f..905c1119 100644 --- a/manifests/feature/api.pp +++ b/manifests/feature/api.pp @@ -8,9 +8,9 @@ class icinga2::feature::api ( $accept_commands = false, $accept_config = false, - $ca_path = '/etc/icinga2/pki/ca.crt', - $cert_path = "/etc/icinga2/pki/${::fqdn}.crt", - $key_path = "/etc/icinga2/pki/${::fqdn}.key", + $ca_path = "${::icinga2::config_dir}/pki/ca.crt", + $cert_path = "${::icinga2::config_dir}/pki/${::fqdn}.crt", + $key_path = "${::icinga2::config_dir}/pki/${::fqdn}.key", $crl_path = undef, $bind_host = undef, $bind_port = undef, diff --git a/manifests/feature/debuglog.pp b/manifests/feature/debuglog.pp index b5f8c5cc..bfe970c7 100644 --- a/manifests/feature/debuglog.pp +++ b/manifests/feature/debuglog.pp @@ -4,7 +4,7 @@ # class icinga2::feature::debuglog ( $severity = 'debug', - $path = '/var/log/icinga2/debug.log' + $path = "${::icinga2::var_dir}/log/icinga2/debug.log" ) { validate_string($severity) diff --git a/manifests/feature/graphite.pp b/manifests/feature/graphite.pp index 5fe5c04c..73f75ece 100644 --- a/manifests/feature/graphite.pp +++ b/manifests/feature/graphite.pp @@ -21,7 +21,7 @@ enable_send_thresholds => $enable_send_thresholds, enable_send_metadata => $enable_send_metadata, enable_legacy_mode => $enable_legacy_mode, - target_dir => '/etc/icinga2/features-available', + target_dir => "${::icinga2::config_dir}/features-available", } ::icinga2::feature { 'graphite': diff --git a/manifests/feature/ido_mysql.pp b/manifests/feature/ido_mysql.pp index 78c492ef..5b19192c 100644 --- a/manifests/feature/ido_mysql.pp +++ b/manifests/feature/ido_mysql.pp @@ -51,7 +51,7 @@ cleanup => $cleanup, categories => $categories, target_file_name => 'ido-mysql.conf', - target_dir => '/etc/icinga2/features-available', + target_dir => "${::icinga2::config_dir}/features-available", } -> ::icinga2::feature { 'ido-mysql': diff --git a/manifests/feature/ido_pgsql.pp b/manifests/feature/ido_pgsql.pp index fed20a74..e3c2a75c 100644 --- a/manifests/feature/ido_pgsql.pp +++ b/manifests/feature/ido_pgsql.pp @@ -51,7 +51,7 @@ cleanup => $cleanup, categories => $categories, target_file_name => 'ido-pgsql.conf', - target_dir => '/etc/icinga2/features-available', + target_dir => "${::icinga2::config_dir}/features-available", } -> ::icinga2::feature { 'ido-pgsql': diff --git a/manifests/feature/mainlog.pp b/manifests/feature/mainlog.pp index 2d987233..c188f2a2 100644 --- a/manifests/feature/mainlog.pp +++ b/manifests/feature/mainlog.pp @@ -4,7 +4,7 @@ # class icinga2::feature::mainlog ( $severity = 'information', - $path = '/var/log/icinga2/icinga2.log' + $path = "${::icinga2::var_dir}/log/icinga2/icinga2.log" ) { validate_string($severity) diff --git a/manifests/init.pp b/manifests/init.pp index 301d814c..b6e6b1e9 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -38,6 +38,10 @@ $db_schema_pgsql = $::icinga2::params::db_schema_pgsql, $pid_file = $::icinga2::params::pid_file, $restart_cmd = $::icinga2::params::restart_cmd, + $config_dir = $::icinga2::params::config_dir, + $sbin_dir = $::icinga2::params::sbin_dir, + $share_dir = $::icinga2::params::share_dir, + $var_dir = $::icinga2::params::var_dir, ) inherits ::icinga2::params { # TODO: temporary parameter until we provide some default templates validate_bool($purge_confd) diff --git a/manifests/object/apiuser.pp b/manifests/object/apiuser.pp index 65b618cf..e69e412e 100644 --- a/manifests/object/apiuser.pp +++ b/manifests/object/apiuser.pp @@ -13,7 +13,7 @@ $password = undef, $client_cn = undef, $permissions = ['*'], - $target_dir = '/etc/icinga2/objects/apiusers', + $target_dir = "${::icinga2::config_dir}/objects/apiusers", $file_name = "${name}.conf", ) { diff --git a/manifests/object/apply_dependency.pp b/manifests/object/apply_dependency.pp index d8afbd8f..03f90116 100644 --- a/manifests/object/apply_dependency.pp +++ b/manifests/object/apply_dependency.pp @@ -23,7 +23,7 @@ $states = [], $assign_where = undef, $ignore_where = undef, - $target_dir = '/etc/icinga2/objects/applys', + $target_dir = "${::icinga2::config_dir}/objects/applys", $target_file_name = "${name}.conf", $target_file_ensure = file, $target_file_owner = $::icinga2::config_owner, diff --git a/manifests/object/apply_notification_to_host.pp b/manifests/object/apply_notification_to_host.pp index 0bd8febe..f1bfaced 100644 --- a/manifests/object/apply_notification_to_host.pp +++ b/manifests/object/apply_notification_to_host.pp @@ -24,7 +24,7 @@ $period = undef, $types = [], $states = [], - $target_dir = '/etc/icinga2/objects/applys', + $target_dir = "${::icinga2::config_dir}/objects/applys", $target_file_name = "${name}.conf", $target_file_ensure = file, $target_file_owner = $::icinga2::config_owner, diff --git a/manifests/object/apply_notification_to_service.pp b/manifests/object/apply_notification_to_service.pp index 51b023e6..e3b25317 100644 --- a/manifests/object/apply_notification_to_service.pp +++ b/manifests/object/apply_notification_to_service.pp @@ -25,7 +25,7 @@ $period = undef, $types = [], $states = [], - $target_dir = '/etc/icinga2/objects/applys', + $target_dir = "${::icinga2::config_dir}/objects/applys", $target_file_name = "${name}.conf", $target_file_ensure = file, $target_file_owner = $::icinga2::config_owner, diff --git a/manifests/object/apply_scheduleddowntime.pp b/manifests/object/apply_scheduleddowntime.pp index 47aa90d0..16485706 100644 --- a/manifests/object/apply_scheduleddowntime.pp +++ b/manifests/object/apply_scheduleddowntime.pp @@ -19,7 +19,7 @@ $ignore_where = undef, $fixed = undef, $duration = undef, - $target_dir = '/etc/icinga2/objects/applys', + $target_dir = "${::icinga2::config_dir}/objects/applys", $file_name = "${name}.conf", ) { diff --git a/manifests/object/apply_service.pp b/manifests/object/apply_service.pp index 85cfc419..76f07d58 100644 --- a/manifests/object/apply_service.pp +++ b/manifests/object/apply_service.pp @@ -40,7 +40,7 @@ $action_url = undef, $icon_image = undef, $icon_image_alt = undef, - $target_dir = '/etc/icinga2/objects/applys', + $target_dir = "${::icinga2::config_dir}/objects/applys", $target_file_name = "${name}.conf", $target_file_ensure = file, $target_file_owner = $::icinga2::config_owner, diff --git a/manifests/object/checkcommand.pp b/manifests/object/checkcommand.pp index 3d23b2d7..27a54f26 100644 --- a/manifests/object/checkcommand.pp +++ b/manifests/object/checkcommand.pp @@ -22,7 +22,7 @@ $refresh_icinga2_service = true, $sudo = false, $sudo_cmd = '/usr/bin/sudo', - $target_dir = '/etc/icinga2/objects/checkcommands', + $target_dir = "${::icinga2::config_dir}/objects/checkcommands", $target_file_ensure = file, $target_file_group = $::icinga2::config_group, $target_file_mode = $::icinga2::config_mode, diff --git a/manifests/object/checkresultreader.pp b/manifests/object/checkresultreader.pp index 602fa33f..959a0ba6 100644 --- a/manifests/object/checkresultreader.pp +++ b/manifests/object/checkresultreader.pp @@ -13,7 +13,7 @@ $ensure = 'file', $object_checkresultreadername = $name, $spool_dir = undef, - $target_dir = '/etc/icinga2/objects/checkresultreaders', + $target_dir = "${::icinga2::config_dir}/objects/checkresultreaders", $target_file_name = "${name}.conf", $target_file_ensure = file, $target_file_owner = $::icinga2::config_owner, diff --git a/manifests/object/compatlogger.pp b/manifests/object/compatlogger.pp index a36a254e..570032fc 100644 --- a/manifests/object/compatlogger.pp +++ b/manifests/object/compatlogger.pp @@ -14,7 +14,7 @@ $object_compatloggername = $name, $log_dir = undef, $rotation_method = undef, - $target_dir = '/etc/icinga2/objects/compatloggers', + $target_dir = "${::icinga2::config_dir}/objects/compatloggers", $target_file_name = "${name}.conf", $target_file_ensure = file, $target_file_owner = $::icinga2::config_owner, diff --git a/manifests/object/dependency.pp b/manifests/object/dependency.pp index 63448dee..d350cb02 100644 --- a/manifests/object/dependency.pp +++ b/manifests/object/dependency.pp @@ -20,7 +20,7 @@ $disable_notifications = undef, $period = undef, $states = [], - $target_dir = '/etc/icinga2/objects/dependencies', + $target_dir = "${::icinga2::config_dir}/objects/dependencies", $target_file_name = "${name}.conf", $target_file_ensure = file, $target_file_owner = $::icinga2::config_owner, diff --git a/manifests/object/endpoint.pp b/manifests/object/endpoint.pp index 5b871118..fc970b28 100644 --- a/manifests/object/endpoint.pp +++ b/manifests/object/endpoint.pp @@ -13,7 +13,7 @@ $host = undef, $port = undef, $log_duration = undef, - $target_dir = '/etc/icinga2/objects/endpoints', + $target_dir = "${::icinga2::config_dir}/objects/endpoints", $file_name = "${name}.conf", ) { diff --git a/manifests/object/eventcommand.pp b/manifests/object/eventcommand.pp index 73520fab..2f572433 100644 --- a/manifests/object/eventcommand.pp +++ b/manifests/object/eventcommand.pp @@ -19,7 +19,7 @@ $env = {}, $vars = {}, $timeout = undef, - $target_dir = '/etc/icinga2/objects/eventcommands', + $target_dir = "${::icinga2::config_dir}/objects/eventcommands", $target_file_name = "${name}.conf", $target_file_ensure = file, $target_file_owner = $::icinga2::config_owner, diff --git a/manifests/object/gelfwriter.pp b/manifests/object/gelfwriter.pp index 90fcbf22..deb71376 100644 --- a/manifests/object/gelfwriter.pp +++ b/manifests/object/gelfwriter.pp @@ -15,7 +15,7 @@ $source = undef, # Put the object files this defined type generates in features-available # since the Gelf writer feature is one that has to be explicitly enabled. - $target_dir = '/etc/icinga2/features-available', + $target_dir = "${::icinga2::config_dir}/features-available", $file_name = "${name}.conf", ) { # Do some validation diff --git a/manifests/object/graphitewriter.pp b/manifests/object/graphitewriter.pp index 219abee5..b1620ef8 100644 --- a/manifests/object/graphitewriter.pp +++ b/manifests/object/graphitewriter.pp @@ -21,7 +21,7 @@ $enable_legacy_mode = undef, # Put the object files this defined type generates in features-available # since the Graphite writer feature is one that has to be explicitly enabled. - $target_dir = '/etc/icinga2/objects/graphitewriters', + $target_dir = "${::icinga2::config_dir}/objects/graphitewriters", $file_name = "${name}.conf", ) { # Do some validation diff --git a/manifests/object/host.pp b/manifests/object/host.pp index fcd2fb59..2be436f7 100644 --- a/manifests/object/host.pp +++ b/manifests/object/host.pp @@ -38,7 +38,7 @@ $action_url = undef, $icon_image = undef, $icon_image_alt = undef, - $target_dir = '/etc/icinga2/objects/hosts', + $target_dir = "${::icinga2::config_dir}/objects/hosts", $target_file_name = "${name}.conf", $target_file_ensure = file, $target_file_owner = $::icinga2::config_owner, diff --git a/manifests/object/hostgroup.pp b/manifests/object/hostgroup.pp index 4c242ec7..500ffbe7 100644 --- a/manifests/object/hostgroup.pp +++ b/manifests/object/hostgroup.pp @@ -14,7 +14,7 @@ $display_name = $name, $templates = [], $groups = [], - $target_dir = '/etc/icinga2/objects/hostgroups', + $target_dir = "${::icinga2::config_dir}/objects/hostgroups", $target_file_name = "${name}.conf", $target_file_ensure = file, $target_file_owner = $::icinga2::config_owner, diff --git a/manifests/object/icingastatuswriter.pp b/manifests/object/icingastatuswriter.pp index 2f942691..9b57e555 100644 --- a/manifests/object/icingastatuswriter.pp +++ b/manifests/object/icingastatuswriter.pp @@ -14,7 +14,7 @@ $object_name = $name, $status_path = undef, $update_interval = undef, - $target_dir = '/etc/icinga2/objects/icingastatuswriters', + $target_dir = "${::icinga2::config_dir}/objects/icingastatuswriters", $target_file_name = "${name}.conf", $target_file_owner = $::icinga2::config_owner, $target_file_group = $::icinga2::config_group, diff --git a/manifests/object/idomysqlconnection.pp b/manifests/object/idomysqlconnection.pp index 114036b5..1d97458e 100644 --- a/manifests/object/idomysqlconnection.pp +++ b/manifests/object/idomysqlconnection.pp @@ -32,7 +32,7 @@ }, $categories = [], $target_file_name = "${name}.conf", - $target_dir = '/etc/icinga2/objects/idomysqlconnections', + $target_dir = "${::icinga2::config_dir}/objects/idomysqlconnections", $refresh_service = $::icinga2::manage_service, ) { diff --git a/manifests/object/idopgsqlconnection.pp b/manifests/object/idopgsqlconnection.pp index c321390c..2f835ae3 100644 --- a/manifests/object/idopgsqlconnection.pp +++ b/manifests/object/idopgsqlconnection.pp @@ -32,7 +32,7 @@ }, $categories = [], $target_file_name = "${name}.conf", - $target_dir = '/etc/icinga2/objects/idopgsqlconnections', + $target_dir = "${::icinga2::config_dir}/objects/idopgsqlconnections", $refresh_service = $::icinga2::manage_service, ) { diff --git a/manifests/object/livestatuslistener.pp b/manifests/object/livestatuslistener.pp index 6bad3406..15f0558a 100644 --- a/manifests/object/livestatuslistener.pp +++ b/manifests/object/livestatuslistener.pp @@ -16,7 +16,7 @@ $bind_port = undef, $socket_path = undef, $compat_log_path = undef, - $target_dir = '/etc/icinga2/objects/livestatuslisteners', + $target_dir = "${::icinga2::config_dir}/objects/livestatuslisteners", $target_file_name = "${name}.conf", $target_file_ensure = file, $target_file_owner = $::icinga2::config_owner, diff --git a/manifests/object/notification.pp b/manifests/object/notification.pp index 0b30eb84..1904a8a1 100644 --- a/manifests/object/notification.pp +++ b/manifests/object/notification.pp @@ -24,7 +24,7 @@ $period = undef, $types = [], $states = [], - $target_dir = '/etc/icinga2/objects/notifications', + $target_dir = "${::icinga2::config_dir}/objects/notifications", $target_file_name = "${name}.conf", $target_file_ensure = file, $target_file_owner = $::icinga2::config_owner, diff --git a/manifests/object/notificationcommand.pp b/manifests/object/notificationcommand.pp index 91c6810e..670827a3 100644 --- a/manifests/object/notificationcommand.pp +++ b/manifests/object/notificationcommand.pp @@ -19,7 +19,7 @@ $env = {}, $vars = {}, $timeout = undef, - $target_dir = '/etc/icinga2/objects/notificationcommands', + $target_dir = "${::icinga2::config_dir}/objects/notificationcommands", $target_file_name = "${name}.conf", $target_file_ensure = file, $target_file_owner = $::icinga2::config_owner, diff --git a/manifests/object/opentsdbwriter.pp b/manifests/object/opentsdbwriter.pp index c97348ce..ec738d89 100644 --- a/manifests/object/opentsdbwriter.pp +++ b/manifests/object/opentsdbwriter.pp @@ -14,7 +14,7 @@ $port = 4242, # Put the object files this defined type generates in features-available # since the Graphite writer feature is one that has to be explicitly enabled. - $target_dir = '/etc/icinga2/features-available', + $target_dir = "${::icinga2::config_dir}/features-available", $file_name = "${name}.conf", ) { # Do some validation diff --git a/manifests/object/perfdatawriter.pp b/manifests/object/perfdatawriter.pp index 9b5b4018..57019bc2 100644 --- a/manifests/object/perfdatawriter.pp +++ b/manifests/object/perfdatawriter.pp @@ -19,7 +19,7 @@ $host_format_template = undef, $service_format_template = undef, $rotation_interval = undef, - $target_dir = '/etc/icinga2/objects/perfdatawriters', + $target_dir = "${::icinga2::config_dir}/objects/perfdatawriters", $target_file_name = "${name}.conf", $target_file_ensure = file, $target_file_owner = $::icinga2::config_owner, diff --git a/manifests/object/scheduleddowntime.pp b/manifests/object/scheduleddowntime.pp index 3a8cc079..f57372a8 100644 --- a/manifests/object/scheduleddowntime.pp +++ b/manifests/object/scheduleddowntime.pp @@ -18,7 +18,7 @@ $fixed = true, $duration = undef, $ranges = {}, - $target_dir = '/etc/icinga2/objects/scheduleddowntimes', + $target_dir = "${::icinga2::config_dir}/objects/scheduleddowntimes", $target_file_name = "${name}.conf", $target_file_ensure = file, $target_file_owner = $::icinga2::config_owner, diff --git a/manifests/object/service.pp b/manifests/object/service.pp index 5074c75d..b9b82ac2 100644 --- a/manifests/object/service.pp +++ b/manifests/object/service.pp @@ -37,7 +37,7 @@ $action_url = undef, $icon_image = undef, $icon_image_alt = undef, - $target_dir = '/etc/icinga2/objects/services', + $target_dir = "${::icinga2::config_dir}/objects/services", $target_file_name = "${name}.conf", $target_file_ensure = file, $target_file_owner = $::icinga2::config_owner, diff --git a/manifests/object/servicegroup.pp b/manifests/object/servicegroup.pp index 012ebc40..852116e5 100644 --- a/manifests/object/servicegroup.pp +++ b/manifests/object/servicegroup.pp @@ -14,7 +14,7 @@ $display_name = $name, $templates = [], $groups = [], - $target_dir = '/etc/icinga2/objects/servicegroups', + $target_dir = "${::icinga2::config_dir}/objects/servicegroups", $target_file_name = "${name}.conf", $target_file_ensure = file, $target_file_owner = $::icinga2::config_owner, diff --git a/manifests/object/statusdatawriter.pp b/manifests/object/statusdatawriter.pp index 16e2bba7..ae658aa1 100644 --- a/manifests/object/statusdatawriter.pp +++ b/manifests/object/statusdatawriter.pp @@ -14,7 +14,7 @@ $status_path = undef, $objects_path = undef, $update_interval = undef, - $target_dir = '/etc/icinga2/objects/statusdatawriters', + $target_dir = "${::icinga2::config_dir}/objects/statusdatawriters", $target_file_name = "${name}.conf", $target_file_ensure = file, $target_file_owner = $::icinga2::config_owner, diff --git a/manifests/object/timeperiod.pp b/manifests/object/timeperiod.pp index 2014c722..d58eb3a6 100644 --- a/manifests/object/timeperiod.pp +++ b/manifests/object/timeperiod.pp @@ -15,7 +15,7 @@ $timeperiod_display_name = undef, $methods = undef, $ranges = {}, - $target_dir = '/etc/icinga2/objects/timeperiods', + $target_dir = "${::icinga2::config_dir}/objects/timeperiods", $target_file_name = "${name}.conf", $target_file_ensure = file, $target_file_owner = $::icinga2::config_owner, diff --git a/manifests/object/user.pp b/manifests/object/user.pp index 5cf689a6..5f1fd023 100644 --- a/manifests/object/user.pp +++ b/manifests/object/user.pp @@ -22,7 +22,7 @@ $period = undef, $types = [], $states = [], - $target_dir = '/etc/icinga2/objects/users', + $target_dir = "${::icinga2::config_dir}/objects/users", $target_file_name = "${name}.conf", $target_file_ensure = file, $target_file_owner = $::icinga2::config_owner, diff --git a/manifests/object/usergroup.pp b/manifests/object/usergroup.pp index 97a05b6d..7d08a730 100644 --- a/manifests/object/usergroup.pp +++ b/manifests/object/usergroup.pp @@ -14,7 +14,7 @@ $display_name = $name, $templates = [], $groups = [], - $target_dir = '/etc/icinga2/objects/usergroups', + $target_dir = "${::icinga2::config_dir}/objects/usergroups", $target_file_name = "${name}.conf", $target_file_ensure = file, $target_file_owner = $::icinga2::config_owner, diff --git a/manifests/object/zone.pp b/manifests/object/zone.pp index 2aaa3043..1de11a85 100644 --- a/manifests/object/zone.pp +++ b/manifests/object/zone.pp @@ -12,7 +12,7 @@ $endpoints = undef, $global = false, $parent = undef, - $target_dir = '/etc/icinga2/objects/zones', + $target_dir = "${::icinga2::config_dir}/objects/zones", $file_name = "${name}.conf", ) { diff --git a/manifests/params.pp b/manifests/params.pp index 991617b1..402aaf4b 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -33,10 +33,6 @@ $db_user = 'icinga2' $db_pass = 'password' - # the schema is currently not OS specific - $db_schema_mysql = '/usr/share/icinga2-ido-mysql/schema/mysql.sql' - $db_schema_pgsql = '/usr/share/icinga2-ido-pgsql/schema/pgsql.sql' - $pid_file = '/run/icinga2/icinga2.pid' $restart_cmd = undef @@ -118,4 +114,39 @@ #Fail if we're on any other OS: default: { fail("${::operatingsystem} is not supported!") } } + + + # i2* is expected to come from the OS recognition, so a OSFAMILY specified attribute takes precedence over the default + if $::i2config_dir { + $config_dir = $::i2config_dir + } + else { + $config_dir = '/etc/icinga2' + } + + if $::i2sbin_dir { + $sbin_dir = $::i2sbin_dir + } + else { + $sbin_dir = '/usr/sbin' + } + + if $::i2share_dir { + $share_dir = $::i2share_dir + } + else { + $share_dir = '/usr/share' + } + + if $::i2var_dir { + $var_dir = $::i2var_dir + } + else { + $var_dir = '/var' + } + + # the schema is now using a set parameter for the os or the default. + $db_schema_mysql = "${share_dir}/icinga2-ido-mysql/schema/mysql.sql" + $db_schema_pgsql = "${share_dir}/icinga2-ido-pgsql/schema/pgsql.sql" + } diff --git a/manifests/pki/icinga.pp b/manifests/pki/icinga.pp index 22600ccf..093b019b 100644 --- a/manifests/pki/icinga.pp +++ b/manifests/pki/icinga.pp @@ -22,7 +22,7 @@ $ticket_id = icinga2_ticket_id($::fqdn, $ticket_salt) - $pki_dir = '/etc/icinga2/pki' + $pki_dir = "${::icinga2::config_dir}/pki" $ca = "${pki_dir}/ca.crt" $key = "${pki_dir}/${hostname}.key" $cert = "${pki_dir}/${hostname}.crt" diff --git a/manifests/pki/puppet.pp b/manifests/pki/puppet.pp index 9fc4fa64..b604a41e 100644 --- a/manifests/pki/puppet.pp +++ b/manifests/pki/puppet.pp @@ -3,13 +3,13 @@ # Provide PKI certificates for Icinga2 from the Puppet agent. # class icinga2::pki::puppet( - $ca_path = '/etc/icinga2/pki/ca.crt', + $ca_path = "${::icinga2::config_dir}/pki/ca.crt", $ca_source = "${::settings::ssldir}/certs/ca.pem", - $cert_path = "/etc/icinga2/pki/${::fqdn}.crt", + $cert_path = "${::icinga2::config_dir}/pki/${::fqdn}.crt", $cert_source = "${::settings::ssldir}/certs/${::fqdn}.pem", - $key_path = "/etc/icinga2/pki/${::fqdn}.key", + $key_path = "${::icinga2::config_dir}/pki/${::fqdn}.key", $key_source = "${::settings::ssldir}/private_keys/${::fqdn}.pem", - $crl_path = '/etc/icinga2/pki/crl.pem', + $crl_path = "${::icinga2::config_dir}/pki/crl.pem", $crl_source = "${::settings::ssldir}/crl.pem", ) { @@ -53,4 +53,4 @@ Class['::icinga2::pki::puppet'] ~> Class['icinga2::service'] } -} \ No newline at end of file +} diff --git a/spec/classes/icinga2_feature_mainlog_spec.rb b/spec/classes/icinga2_feature_mainlog_spec.rb index 233f1c64..260ad2fb 100644 --- a/spec/classes/icinga2_feature_mainlog_spec.rb +++ b/spec/classes/icinga2_feature_mainlog_spec.rb @@ -39,4 +39,19 @@ class { 'icinga2::feature::mainlog': })} end + context "on #{default} with var_dir parameters" do + let :pre_condition do + "class { 'icinga2': + default_features => false, + var_dir => '/var/opt', + }" + end + + it { should contain_class('icinga2::feature::mainlog') } + it { should contain_icinga2__feature('mainlog') } + it { should contain_file('icinga2 feature mainlog').with({ + :content => /severity = "information"\n\s+path = "\/var\/opt\/log\/icinga2\/icinga2\.log"/, + })} + end + end diff --git a/spec/defines/icinga2_feature_spec.rb b/spec/defines/icinga2_feature_spec.rb index 2b0e835f..1959a7dd 100644 --- a/spec/defines/icinga2_feature_spec.rb +++ b/spec/defines/icinga2_feature_spec.rb @@ -26,7 +26,7 @@ it { should contain_file('icinga2 feature checker enabled').with({ :ensure => 'link', :path => '/etc/icinga2/features-enabled/checker.conf', - :target => '../features-available/checker.conf', + :target => '/etc/icinga2/features-available/checker.conf', })} it { is_expected.to contain_file("icinga2 feature checker").that_notifies('Class[icinga2::service]') } end @@ -57,5 +57,59 @@ it { is_expected.not_to contain_file("icinga2 feature checker").that_notifies('Class[icinga2::service]') } end + context "on default #{default} with config_dir parameters" do + let :facts do + IcingaPuppet.variants[default] + end + let :pre_condition do + "class { 'icinga2': + default_features => false, + config_dir => '/tmp', + }" + end + + let(:title) { 'checker' } + + it { should contain_icinga2__feature('checker') } + it { should contain_file('icinga2 feature checker').with({ + :ensure => 'file', + :path => '/tmp/features-available/checker.conf', + :content => /CheckerComponent/, + })} + it { should contain_file('icinga2 feature checker enabled').with({ + :ensure => 'link', + :path => '/tmp/features-enabled/checker.conf', + :target => '/tmp/features-available/checker.conf', + })} + it { is_expected.to contain_file("icinga2 feature checker").that_notifies('Class[icinga2::service]') } + end + + context "on default #{default} with var_dir and config_dir parameters" do + let :facts do + IcingaPuppet.variants[default] + end + let :pre_condition do + "class { 'icinga2': + default_features => false, + config_dir => '/tmp/config', + var_dir => '/tmp/var', + }" + end + + let(:title) { 'checker' } + + it { should contain_icinga2__feature('checker') } + it { should contain_file('icinga2 feature checker').with({ + :ensure => 'file', + :path => '/tmp/config/features-available/checker.conf', + :content => /CheckerComponent/, + })} + it { should contain_file('icinga2 feature checker enabled').with({ + :ensure => 'link', + :path => '/tmp/config/features-enabled/checker.conf', + :target => '/tmp/config/features-available/checker.conf', + })} + it { is_expected.to contain_file("icinga2 feature checker").that_notifies('Class[icinga2::service]') } + end end