Commit 7333d43a authored by Markus Frosch's avatar Markus Frosch 📣

selftest: Extend config collection

parent c0fd9cfd
class icinga2_testing::profiles::selftest(
class icinga2_testing::profiles::selftest (
$zone = 'master',
) {
include ::icinga2_testing::profiles::icinga2
......@@ -22,28 +22,31 @@ class icinga2_testing::profiles::selftest(
$_zones = hiera_hash('icinga2::object::zone')
file {
$config_base:
ensure => directory,
force => true,
purge => true,
recurse => true;
"${config_base}/templates.conf":
ensure => file,
content => template('icinga2_testing/selftest/templates.conf.erb');
"${config_base}/hosts.conf":
ensure => file,
content => template('icinga2_testing/selftest/hosts.conf.erb');
"${config_base}/services.conf":
file { $config_base:
ensure => directory,
force => true,
purge => true,
recurse => true,
}
['hosts', 'services'].each |$name| {
file { "${config_base}/${name}.conf":
ensure => file,
content => template('icinga2_testing/selftest/services.conf.erb');
"${global_zone}/selftest":
ensure => directory,
force => true,
purge => true,
recurse => true;
"${global_zone}/selftest/commands.conf":
content => template("icinga2_testing/selftest/${name}.conf.erb"),
}
}
file { "${global_zone}/selftest":
ensure => directory,
force => true,
purge => true,
recurse => true;
}
['commands', 'templates', 'timeperiods', 'users'].each |$name| {
file { "${global_zone}/selftest/${name}.conf":
ensure => file,
content => template('icinga2_testing/selftest/commands.conf.erb');
content => template("icinga2_testing/selftest/${name}.conf.erb"),
}
}
}
\ No newline at end of file
......@@ -20,3 +20,34 @@ object CheckCommand "updates" {
vars.updates_yum_arguments = "--cacheonly"
}
object NotificationCommand "log-host-notification" {
command = [ SysconfDir + "/icinga2/scripts/log-notification.sh" ]
env = {
OBJECT = "host"
NOTIFICATIONTYPE = "$notification.type$"
HOSTNAME = "$host.name$"
STATE = "$host.state$"
OUTPUT = "$host.output$"
NOTIFICATIONAUTHORNAME = "$notification.author$"
NOTIFICATIONCOMMENT = "$notification.comment$"
USERNAME = "$user.name$"
}
}
object NotificationCommand "log-service-notification" {
command = [ SysconfDir + "/icinga2/scripts/log-notification.sh" ]
env = {
OBJECT = "service"
NOTIFICATIONTYPE = "$notification.type$"
SERVICEDESC = "$service.name$"
HOSTNAME = "$host.name$"
STATE = "$service.state$"
OUTPUT = "$service.output$"
NOTIFICATIONAUTHORNAME = "$notification.author$"
NOTIFICATIONCOMMENT = "$notification.comment$"
USERNAME = "$user.name$"
}
}
#######################################
# Icinga 2 selftest configuration
# Managed by Puppet
#######################################
apply Notification "log" to Host {
import "log-notification"
user_groups = ["test"]
assign where host.vars.notification == "test"
}
apply Notification "log" to Service {
import "log-notification"
user_groups = ["test"]
assign where service.vars.notification == "test"
}
......@@ -44,8 +44,13 @@ apply Service "icinga ido" {
check_command = "ido"
vars.ido_type = "IdoMysqlConnection"
vars.ido_name = "ido-mysql"
if (match("*master2*", host.name)) {
vars.ido_type = "IdoPgsqlConnection"
vars.ido_name = "ido-pgsql"
} else {
vars.ido_type = "IdoMysqlConnection"
vars.ido_name = "ido-mysql"
}
assign where host.vars.role == "icinga" && host.vars.zone == "master"
}
......
......@@ -26,3 +26,25 @@ template Service "agent-service" {
template User "generic-user" {
}
template Notification "mail-host-notification" {
command = "log-notification"
states = [ Up, Down ]
types = [ Problem, Acknowledgement, Recovery, Custom,
FlappingStart, FlappingEnd,
DowntimeStart, DowntimeEnd, DowntimeRemoved ]
period = "24x7"
}
template Notification "mail-service-notification" {
command = "log-notification"
states = [ OK, Warning, Critical, Unknown ]
types = [ Problem, Acknowledgement, Recovery, Custom,
FlappingStart, FlappingEnd,
DowntimeStart, DowntimeEnd, DowntimeRemoved ]
period = "24x7"
}
#######################################
# Icinga 2 selftest configuration
# Managed by Puppet
#######################################
#######################################
# Icinga 2 selftest configuration
# Managed by Puppet
#######################################
#######################################
# Icinga 2 selftest configuration
# Managed by Puppet
#######################################
object TimePeriod "24x7" {
import "legacy-timeperiod"
display_name = "Icinga 2 24x7 TimePeriod"
ranges = {
"monday" = "00:00-24:00"
"tuesday" = "00:00-24:00"
"wednesday" = "00:00-24:00"
"thursday" = "00:00-24:00"
"friday" = "00:00-24:00"
"saturday" = "00:00-24:00"
"sunday" = "00:00-24:00"
}
}
#######################################
# Icinga 2 selftest configuration
# Managed by Puppet
#######################################
object UserGroup "test" {
display_name = "Test Notification"
}
object User "test" {
display_name = "Test Notification"
groups = ["test"]
}
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