Merge branch 'feature/vagrant-icinga2-core-6127'
Switch core for Icinga Web to Icinga2 package install and add test configuration. Consider: Run 'vagrant priovion' and remove /etc/icingaweb configuration folder to install new core and let new icingaweb configuration take place. resolves #6127
This commit is contained in:
commit
b9e138a359
|
@ -0,0 +1,48 @@
|
|||
/* Command objects */
|
||||
|
||||
object CheckCommand "kernel" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ "sudo", SysconfDir + "/icinga2/scripts/check_kernel" ]
|
||||
}
|
||||
|
||||
object NotificationCommand "mail-host-notification" {
|
||||
import "plugin-notification-command"
|
||||
|
||||
command = [ "/bin/true" ]
|
||||
|
||||
env = {
|
||||
"NOTIFICATIONTYPE" = "$notification.type$"
|
||||
"HOSTALIAS" = "$host.display_name$",
|
||||
"HOSTADDRESS" = "$address$",
|
||||
"HOSTSTATE" = "$host.state$",
|
||||
"LONGDATETIME" = "$icinga.long_date_time$",
|
||||
"HOSTOUTPUT" = "$host.output$",
|
||||
"NOTIFICATIONAUTHORNAME" = "$notification.author$",
|
||||
"NOTIFICATIONCOMMENT" = "$notification.comment$",
|
||||
"HOSTDISPLAYNAME" = "$host.display_name$",
|
||||
"USEREMAIL" = "$user.email$"
|
||||
}
|
||||
}
|
||||
|
||||
object NotificationCommand "mail-service-notification" {
|
||||
import "plugin-notification-command"
|
||||
|
||||
command = [ "/bin/true" ]
|
||||
|
||||
env = {
|
||||
"NOTIFICATIONTYPE" = "$notification.type$"
|
||||
"SERVICEDESC" = "$service.name$"
|
||||
"HOSTALIAS" = "$host.display_name$",
|
||||
"HOSTADDRESS" = "$address$",
|
||||
"SERVICESTATE" = "$service.state$",
|
||||
"LONGDATETIME" = "$icinga.long_date_time$",
|
||||
"SERVICEOUTPUT" = "$service.output$",
|
||||
"NOTIFICATIONAUTHORNAME" = "$notification.author$",
|
||||
"NOTIFICATIONCOMMENT" = "$notification.comment$",
|
||||
"HOSTDISPLAYNAME" = "$host.display_name$",
|
||||
"SERVICEDISPLAYNAME" = "$service.display_name$",
|
||||
"USEREMAIL" = "$user.email$"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,174 @@
|
|||
|
||||
template CheckCommand "dummy-host-generic" {
|
||||
import "plugin-check-command"
|
||||
command = [ PluginDir + "/libexec/test_hostcheck.pl" ]
|
||||
arguments = {
|
||||
"--type" = "$check_type$"
|
||||
"--failchance" = "$check_failchance$"
|
||||
"--previous-state" = "$check_previous_state$"
|
||||
"--state-duration" = "$check_state_duration$"
|
||||
"--hostname" = "$check_hostname$"
|
||||
}
|
||||
|
||||
vars.check_type = "UP"
|
||||
vars.check_failchance = "2%"
|
||||
vars.check_previous_state = "$state$"
|
||||
vars.check_state_duration = "$duration_sec$"
|
||||
vars.check_hostname = "$name$"
|
||||
}
|
||||
|
||||
template CheckCommand "dummy-service-generic" {
|
||||
import "plugin-check-command"
|
||||
command = [ PluginDir + "/libexec/test_servicecheck.pl" ]
|
||||
arguments = {
|
||||
"--total-critical-on-host" = "$check_critical_on_host$"
|
||||
"--total-warning-on-host" = "$check_warning_on_host$"
|
||||
"--type" = "$check_type$"
|
||||
"--failchance" = "$check_failchance$"
|
||||
"--previous-state" = "$check_previous_state$"
|
||||
"--state-duration" = "$check_state_duration$"
|
||||
"--hostname" = "$check_hostname$"
|
||||
"--servicedesc" = "$check_servicedesc$"
|
||||
}
|
||||
vars.check_critical_on_host = "$host.total_services_critical$"
|
||||
vars.check_warning_on_host = "$host.total_services_warning$"
|
||||
vars.check_type = "random"
|
||||
vars.check_failchange = "5%"
|
||||
vars.check_previous_state = "$service.state$"
|
||||
vars.check_duration = "$service.duration_sec$"
|
||||
vars.check_hostname = "$host.name$"
|
||||
vars.check_servicedesc = "$service.name$"
|
||||
}
|
||||
|
||||
// Concrete check commands
|
||||
object CheckCommand "dummy-host" {
|
||||
import "dummy-host-generic"
|
||||
}
|
||||
|
||||
object CheckCommand "dummy-service" {
|
||||
import "dummy-service-generic"
|
||||
}
|
||||
|
||||
// Hostgroups
|
||||
object HostGroup "all-hosts" {
|
||||
display_name = "All hosts on the system"
|
||||
assign where true
|
||||
}
|
||||
|
||||
object HostGroup "all-ok" {
|
||||
display_name = "All ok hosts"
|
||||
assign where regex("^test-ok", host.name)
|
||||
}
|
||||
|
||||
object HostGroup "all-chaos" {
|
||||
display_name = "All chaos hosts"
|
||||
assign where regex("^test-random", host.name)
|
||||
}
|
||||
|
||||
object HostGroup "all-down" {
|
||||
display_name = "All down hosts"
|
||||
assign where regex("^test-down", host.name)
|
||||
}
|
||||
|
||||
object HostGroup "all-up" {
|
||||
display_name = "All ok hosts"
|
||||
assign where regex("^test-ok", host.name)
|
||||
}
|
||||
|
||||
object HostGroup "all-unreachable" {
|
||||
display_name = "All ok hosts"
|
||||
assign where regex("^test-unreachable", host.name)
|
||||
}
|
||||
|
||||
object HostGroup "all-pending" {
|
||||
display_name = "All ok hosts"
|
||||
assign where regex("^test-pending", host.name)
|
||||
}
|
||||
|
||||
// Servicegroups
|
||||
object ServiceGroup "service-ok" {
|
||||
display_name = "All ok services"
|
||||
assign where regex("^service-ok", service.name)
|
||||
}
|
||||
|
||||
object ServiceGroup "service-warning" {
|
||||
display_name = "All warning services"
|
||||
assign where regex("^service-warning", service.name)
|
||||
}
|
||||
|
||||
object ServiceGroup "service-critical" {
|
||||
display_name = "All critical services"
|
||||
assign where regex("^service-critical", service.name)
|
||||
}
|
||||
|
||||
object ServiceGroup "service-unknown" {
|
||||
display_name = "All unknown services"
|
||||
assign where regex("^service-unknown", service.name)
|
||||
}
|
||||
|
||||
object ServiceGroup "service-flapping" {
|
||||
display_name = "All flapping services"
|
||||
assign where regex("^service-flapping", service.name)
|
||||
}
|
||||
|
||||
|
||||
object ServiceGroup "service-pending" {
|
||||
display_name = "All pending services"
|
||||
assign where regex("^service-pending", service.name)
|
||||
}
|
||||
|
||||
// Config helper
|
||||
function loop(count, func) {
|
||||
count == 1 || loop(count - 1, func)
|
||||
func(count)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------------
|
||||
// Services
|
||||
// ---------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function createService(filter, num, checkEnabled) {
|
||||
apply Service "service-" + filter + "-" + string(num) {
|
||||
import "generic-service"
|
||||
check_command = "dummy-service"
|
||||
enable_active_checks = checkEnabled
|
||||
vars.check_type = filter
|
||||
assign where match("*" + filter + "*", host.vars.check_config)
|
||||
}
|
||||
}
|
||||
|
||||
loop(4, lambda num: {
|
||||
createService("ok", num, true)
|
||||
createService("warning", num, true)
|
||||
createService("critical", num, true)
|
||||
createService("flap", num, true)
|
||||
createService("random", num, true)
|
||||
createService("unknown", num, true)
|
||||
createService("pending", num, false)
|
||||
})
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------------
|
||||
// Hosts
|
||||
// ---------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function createHost(checkType, checkConfig, num, checkEnabled) {
|
||||
object Host "test-" + checkType + "-" + string(num) {
|
||||
import "generic-host"
|
||||
address = "127.0.0.1"
|
||||
check_command = "dummy-host"
|
||||
enable_active_checks = checkEnabled
|
||||
vars.check_type = checkType
|
||||
vars.check_config = checkConfig
|
||||
}
|
||||
}
|
||||
|
||||
loop(10, lambda num: {
|
||||
createHost("ok", "ok", num, true)
|
||||
createHost("random", "random,flap", num, true)
|
||||
createHost("down", "warning,critical", num, true)
|
||||
createHost("unreachable", "unknown", num, true)
|
||||
createHost("pending", "pending", num, false)
|
||||
createHost("flap", "flap", num, true)
|
||||
})
|
||||
|
||||
// EOF
|
|
@ -0,0 +1,13 @@
|
|||
/**
|
||||
* The db_ido_mysql library implements IDO functionality
|
||||
* for MySQL.
|
||||
*/
|
||||
|
||||
library "db_ido_mysql"
|
||||
|
||||
object IdoMysqlConnection "ido-mysql" {
|
||||
user = "icinga2",
|
||||
password = "icinga2",
|
||||
host = "localhost",
|
||||
database = "icinga2"
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
/**
|
||||
* The db_ido_pgsql library implements IDO functionality
|
||||
* for PostgreSQL.
|
||||
*/
|
||||
|
||||
library "db_ido_pgsql"
|
||||
|
||||
object IdoPgsqlConnection "ido-pgsql" {
|
||||
user = "icinga2",
|
||||
password = "icinga2",
|
||||
host = "localhost",
|
||||
database = "icinga2"
|
||||
}
|
|
@ -1,2 +1,2 @@
|
|||
[icinga]
|
||||
path = "/usr/local/icinga-mysql/var/rw/icinga.cmd"
|
||||
path = "/var/run/icinga2/cmd/icinga2.cmd"
|
||||
|
|
|
@ -12,9 +12,9 @@ type = db
|
|||
db = mysql
|
||||
host = localhost
|
||||
port = 3306
|
||||
password = icinga
|
||||
username = icinga
|
||||
dbname = icinga
|
||||
password = icinga2
|
||||
username = icinga2
|
||||
dbname = icinga2
|
||||
|
||||
[statusdat]
|
||||
type = statusdat
|
||||
|
|
|
@ -5,17 +5,25 @@ include openldap
|
|||
|
||||
Exec { path => '/bin:/usr/bin:/sbin' }
|
||||
|
||||
$icingaVersion = '1.9.4'
|
||||
$icinga2Version = '0.0.6'
|
||||
$icingaVersion = '1.11.2'
|
||||
$icinga2Version = '0.0.10'
|
||||
|
||||
exec { 'create-mysql-icinga-db':
|
||||
unless => 'mysql -uicinga -picinga icinga',
|
||||
command => 'mysql -uroot -e "CREATE DATABASE icinga; \
|
||||
GRANT ALL ON icinga.* TO icinga@localhost \
|
||||
GRANT SELECT,INSERT,UPDATE,DELETE ON icinga.* TO icinga@localhost \
|
||||
IDENTIFIED BY \'icinga\';"',
|
||||
require => Service['mysqld']
|
||||
}
|
||||
|
||||
exec { 'create-mysql-icinga2-db':
|
||||
unless => 'mysql -uicinga2 -picinga2 icinga2',
|
||||
command => 'mysql -uroot -e "CREATE DATABASE icinga2; \
|
||||
GRANT SELECT,INSERT,UPDATE,DELETE ON icinga2.* to icinga2@localhost \
|
||||
IDENTIFIED BY \'icinga2\';"',
|
||||
require => Service['mysqld']
|
||||
}
|
||||
|
||||
exec{ 'create-pgsql-icinga-db':
|
||||
unless => 'sudo -u postgres psql -tAc "SELECT 1 FROM pg_roles WHERE rolname=\'icinga\'" | grep -q 1',
|
||||
command => 'sudo -u postgres psql -c "CREATE ROLE icinga WITH LOGIN PASSWORD \'icingaweb\';" && \
|
||||
|
@ -40,6 +48,11 @@ group { 'icinga-cmd':
|
|||
ensure => present
|
||||
}
|
||||
|
||||
group { 'icingacmd':
|
||||
ensure => present,
|
||||
require => Exec['install icinga2']
|
||||
}
|
||||
|
||||
user { 'icinga':
|
||||
ensure => present,
|
||||
groups => 'icinga-cmd',
|
||||
|
@ -47,8 +60,8 @@ user { 'icinga':
|
|||
}
|
||||
|
||||
user { 'apache':
|
||||
groups => ['icinga-cmd', 'vagrant'],
|
||||
require => [ Class['apache'], Group['icinga-cmd'] ]
|
||||
groups => ['icinga-cmd', 'vagrant', 'icingacmd'],
|
||||
require => [ Class['apache'], Group['icinga-cmd'], Group['icingacmd'] ]
|
||||
}
|
||||
|
||||
cmmi { 'icinga-mysql':
|
||||
|
@ -104,7 +117,7 @@ file { '/etc/init.d/ido2db-pgsql':
|
|||
|
||||
exec { 'populate-icinga-mysql-db':
|
||||
unless => 'mysql -uicinga -picinga icinga -e "SELECT * FROM icinga_dbversion;" &> /dev/null',
|
||||
command => "mysql -uicinga -picinga icinga < /usr/local/src/icinga-mysql/icinga-${icingaVersion}/module/idoutils/db/mysql/mysql.sql",
|
||||
command => "mysql -uroot icinga < /usr/local/src/icinga-mysql/icinga-${icingaVersion}/module/idoutils/db/mysql/mysql.sql",
|
||||
require => [ Cmmi['icinga-mysql'], Exec['create-mysql-icinga-db'] ]
|
||||
}
|
||||
|
||||
|
@ -330,7 +343,91 @@ package { ['cmake', 'boost-devel', 'bison', 'flex']:
|
|||
ensure => installed
|
||||
}
|
||||
|
||||
#cmmi { 'icinga2':
|
||||
yumrepo { 'icinga2-repo':
|
||||
baseurl => "http://packages.icinga.org/epel/6/snapshot/",
|
||||
enabled => '0',
|
||||
gpgcheck => '1',
|
||||
gpgkey => 'http://packages.icinga.org/icinga.key',
|
||||
descr => "Icinga Repository - ${::architecture}"
|
||||
}
|
||||
|
||||
exec { 'install icinga2':
|
||||
command => 'yum -d 0 -e 0 -y --enablerepo=icinga2-repo install icinga2',
|
||||
unless => 'rpm -qa | grep icinga2',
|
||||
require => Yumrepo['icinga2-repo']
|
||||
}
|
||||
|
||||
exec { 'install icinga2-classicui-config':
|
||||
command => 'yum -d 0 -e 0 -y --enablerepo=icinga2-repo install icinga2-classicui-config',
|
||||
unless => 'rpm -qa | grep icinga2-classicui-config',
|
||||
require => [ Yumrepo['icinga2-repo'], Exec['install icinga2'], Exec['install icinga2-ido-mysql'] ]
|
||||
}
|
||||
|
||||
exec { 'install icinga2-ido-mysql':
|
||||
command => 'yum -d 0 -e 0 -y --enablerepo=icinga2-repo install icinga2-ido-mysql',
|
||||
unless => 'rpm -qa | grep icinga2-ido-mysql',
|
||||
require => [ Yumrepo['icinga2-repo'], Exec['install icinga2'] ],
|
||||
}
|
||||
|
||||
exec { 'install nagios-plugins-all':
|
||||
command => 'yum -d 0 -e 0 -y --enablerepo=epel install nagios-plugins-all',
|
||||
unless => 'rpm -qa | grep nagios-plugins-all',
|
||||
require => [ Class['epel'], Exec['install icinga2'] ],
|
||||
}
|
||||
|
||||
file { '/etc/icinga2/features-enabled/':
|
||||
ensure => directory,
|
||||
owner => icinga,
|
||||
group => icinga,
|
||||
require => Exec['install icinga2-ido-mysql']
|
||||
}
|
||||
|
||||
file { '/etc/icinga2/features-available/ido-mysql.conf':
|
||||
source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icinga2/features-available/ido-mysql.conf',
|
||||
owner => 'icinga',
|
||||
group => 'icinga',
|
||||
require => Exec['install icinga2-ido-mysql']
|
||||
}
|
||||
|
||||
file { '/etc/icinga2/features-enabled/ido-mysql.conf':
|
||||
ensure => 'link',
|
||||
target => '/etc/icinga2/features-available/ido-mysql.conf',
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
require => Exec['install icinga2-ido-mysql']
|
||||
}
|
||||
|
||||
file { '/etc/icinga2/conf.d/test-config.conf':
|
||||
source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icinga2/conf.d/test-config.conf',
|
||||
owner => 'icinga',
|
||||
group => 'icinga',
|
||||
require => [ Exec['install icinga2'], Exec['create_monitoring_test_config'] ]
|
||||
}
|
||||
|
||||
file { '/etc/icinga2/conf.d/commands.conf':
|
||||
source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icinga2/conf.d/commands.conf',
|
||||
owner => 'icinga',
|
||||
group => 'icinga',
|
||||
require => Exec['install icinga2']
|
||||
}
|
||||
|
||||
service { 'icinga2':
|
||||
ensure => running,
|
||||
require => [
|
||||
Exec['install icinga2'],
|
||||
File['/etc/icinga2/features-enabled/ido-mysql.conf'],
|
||||
File['/etc/icinga2/conf.d/test-config.conf'],
|
||||
File['/etc/icinga2/conf.d/commands.conf']
|
||||
]
|
||||
}
|
||||
|
||||
exec { 'populate-icinga2-mysql-db':
|
||||
unless => 'mysql -uicinga2 -picinga2 icinga2 -e "SELECT * FROM icinga_dbversion;" &> /dev/null',
|
||||
command => "mysql -uroot icinga2 < /usr/share/doc/icinga2-ido-mysql-$icinga2Version/schema/mysql.sql",
|
||||
require => [ Exec['create-mysql-icinga2-db'], Exec['install icinga2-ido-mysql'] ]
|
||||
}
|
||||
|
||||
# cmmi { 'icinga2':
|
||||
# url => "https://github.com/Icinga/icinga2/releases/download/v${icinga2Version}/icinga2-${icinga2Version}.tar.gz",
|
||||
# output => "icinga2-${icinga2Version}.tar.gz",
|
||||
# configure_command => 'mkdir build &> /dev/null || true && cd build && sudo cmake ..',
|
||||
|
@ -338,7 +435,7 @@ package { ['cmake', 'boost-devel', 'bison', 'flex']:
|
|||
# make => 'true && cd build/ && make && make install',
|
||||
# require => Package[ ['cmake', 'boost-devel', 'bison', 'flex'] ],
|
||||
# make_timeout => 900
|
||||
#}
|
||||
# }
|
||||
|
||||
#configure { 'icingaweb':
|
||||
# path => '/vagrant',
|
||||
|
@ -699,6 +796,6 @@ file { '/etc/icingaweb/dashboard/dashboard.ini':
|
|||
group => 'apache',
|
||||
}
|
||||
|
||||
pear::package { 'deepend/Mockery':
|
||||
channel => 'pear.survivethedeepend.com'
|
||||
}
|
||||
# pear::package { 'deepend/Mockery':
|
||||
# channel => 'pear.survivethedeepend.com'
|
||||
# }
|
||||
|
|
Loading…
Reference in New Issue