2013-10-13 17:15:35 +02:00
|
|
|
include apache
|
|
|
|
include mysql
|
2013-10-13 19:20:43 +02:00
|
|
|
# enable when icinga2-ido-pgsql is ready
|
|
|
|
#include pgsql
|
2013-10-13 17:15:35 +02:00
|
|
|
include epel
|
|
|
|
include icinga-rpm-snapshot
|
|
|
|
|
|
|
|
Exec { path => '/bin:/usr/bin:/sbin:/usr/sbin' }
|
|
|
|
|
|
|
|
exec { 'create-mysql-icinga2-ido-db':
|
|
|
|
unless => 'mysql -uicinga -picinga icinga',
|
|
|
|
command => 'mysql -uroot -e "CREATE DATABASE icinga; \
|
|
|
|
GRANT ALL ON icinga.* TO icinga@localhost \
|
|
|
|
IDENTIFIED BY \'icinga\';"',
|
|
|
|
require => Service['mysqld']
|
|
|
|
}
|
|
|
|
|
2013-10-14 14:12:32 +02:00
|
|
|
exec { 'create-mysql-icinga-web-db':
|
|
|
|
unless => 'mysql -uicinga_web -picinga_web icinga_web',
|
|
|
|
command => 'mysql -uroot -e "CREATE DATABASE icinga_web; \
|
|
|
|
GRANT ALL ON icinga_web.* TO icinga_web@localhost \
|
|
|
|
IDENTIFIED BY \'icinga_web\';"',
|
|
|
|
require => Service['mysqld']
|
|
|
|
}
|
|
|
|
|
2013-10-13 19:20:43 +02:00
|
|
|
# enable when icinga2-ido-pgsql is ready
|
2013-10-13 17:15:35 +02:00
|
|
|
#exec { 'create-pgsql-icinga2-ido-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 \'icinga\';" && \
|
|
|
|
# sudo -u postgres createdb -O icinga -E UTF8 icinga && \
|
|
|
|
# sudo -u postgres createlang plpgsql icinga',
|
|
|
|
# require => Service['postgresql']
|
|
|
|
#}
|
|
|
|
|
2013-10-13 19:20:43 +02:00
|
|
|
php::extension { ['php-mysql']:
|
|
|
|
require => [ Class['mysql'] ]
|
2013-10-13 17:15:35 +02:00
|
|
|
}
|
|
|
|
|
2013-10-13 19:20:43 +02:00
|
|
|
# enable when icinga2-ido-pgsql is ready
|
|
|
|
#php::extension { ['php-pgsql']:
|
|
|
|
# require => [ Class['pgsql'] ]
|
|
|
|
#}
|
|
|
|
|
|
|
|
# runtime users
|
2013-10-13 17:15:35 +02:00
|
|
|
group { 'icinga-cmd':
|
|
|
|
ensure => present
|
|
|
|
}
|
|
|
|
|
|
|
|
user { 'icinga':
|
|
|
|
ensure => present,
|
|
|
|
groups => 'icinga-cmd',
|
|
|
|
managehome => false
|
|
|
|
}
|
|
|
|
|
|
|
|
user { 'apache':
|
|
|
|
groups => ['icinga-cmd', 'vagrant'],
|
|
|
|
require => [ Class['apache'], Group['icinga-cmd'] ]
|
|
|
|
}
|
|
|
|
|
|
|
|
file { '/etc/profile.d/env.sh':
|
|
|
|
source => 'puppet:////vagrant/.vagrant-puppet/files/etc/profile.d/env.sh'
|
|
|
|
}
|
|
|
|
|
2013-10-13 19:20:43 +02:00
|
|
|
# nagios plugins from epel
|
|
|
|
package { 'nagios-plugins-all':
|
|
|
|
ensure => installed,
|
|
|
|
require => Class['epel']
|
|
|
|
}
|
2013-10-13 17:15:35 +02:00
|
|
|
|
2013-10-13 19:20:43 +02:00
|
|
|
# these package require the icinga-rpm-snapshot repository installed
|
|
|
|
$icinga2_main_packages = [ 'icinga2', 'icinga2-doc', 'icinga2-ido-mysql', 'icinga-gui' ]
|
2013-10-13 17:15:35 +02:00
|
|
|
|
2013-10-13 19:20:43 +02:00
|
|
|
# workaround for package conflicts
|
|
|
|
# icinga-gui pulls icinga-gui-config automatically
|
|
|
|
package { 'icinga2-classicui-config':
|
2013-10-13 17:15:35 +02:00
|
|
|
ensure => installed,
|
2013-10-13 19:20:43 +02:00
|
|
|
before => Package["icinga-gui"],
|
2013-10-13 17:15:35 +02:00
|
|
|
require => Class['icinga-rpm-snapshot']
|
|
|
|
}
|
2013-10-13 19:20:43 +02:00
|
|
|
|
|
|
|
package { $icinga2_main_packages:
|
2013-10-13 17:15:35 +02:00
|
|
|
ensure => installed,
|
2013-10-14 14:54:15 +02:00
|
|
|
require => Class['icinga-rpm-snapshot'],
|
|
|
|
notify => Service['apache']
|
2013-10-13 17:15:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-14 14:12:32 +02:00
|
|
|
package { 'icinga-web':
|
|
|
|
ensure => installed,
|
2013-10-14 14:54:15 +02:00
|
|
|
require => Class['icinga-rpm-snapshot'],
|
|
|
|
notify => Service['apache']
|
2013-10-14 14:12:32 +02:00
|
|
|
}
|
|
|
|
|
2013-10-13 19:20:43 +02:00
|
|
|
# enable http 80
|
2013-10-13 17:15:35 +02:00
|
|
|
exec { 'iptables-allow-http':
|
|
|
|
unless => 'grep -Fxqe "-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT" /etc/sysconfig/iptables',
|
2013-10-14 17:52:03 +02:00
|
|
|
command => 'lokkit --enabled --service=http'
|
2013-10-13 17:15:35 +02:00
|
|
|
}
|
|
|
|
|
2013-10-13 19:20:43 +02:00
|
|
|
# icinga 2 docs at /icinga2-doc
|
2013-10-13 17:15:35 +02:00
|
|
|
file { '/etc/httpd/conf.d/icinga2-doc.conf':
|
|
|
|
source => 'puppet:////vagrant/.vagrant-puppet/files/etc/httpd/conf.d/icinga2-doc.conf',
|
|
|
|
require => [ Package['apache'], Package['icinga2-doc'] ],
|
|
|
|
notify => Service['apache']
|
|
|
|
}
|
|
|
|
|
2013-10-13 19:20:43 +02:00
|
|
|
# users
|
2013-10-13 17:15:35 +02:00
|
|
|
file { '/etc/motd':
|
|
|
|
source => 'puppet:////vagrant/.vagrant-puppet/files/etc/motd',
|
|
|
|
owner => root,
|
|
|
|
group => root
|
|
|
|
}
|
|
|
|
|
|
|
|
user { 'vagrant':
|
|
|
|
groups => 'icinga-cmd',
|
|
|
|
require => Group['icinga-cmd']
|
|
|
|
}
|
|
|
|
|
2013-10-13 19:20:43 +02:00
|
|
|
# icinga2 service & features
|
2013-10-13 17:15:35 +02:00
|
|
|
service { 'icinga2':
|
|
|
|
enable => true,
|
|
|
|
ensure => running,
|
2013-10-13 21:53:11 +02:00
|
|
|
hasrestart => true,
|
2013-10-13 17:15:35 +02:00
|
|
|
require => Package['icinga2']
|
|
|
|
}
|
|
|
|
|
2013-10-14 09:48:00 +02:00
|
|
|
# icinga 2 IDO config
|
|
|
|
file { '/etc/icinga2/features-available/ido-mysql.conf':
|
|
|
|
source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icinga2/features-available/ido-mysql.conf',
|
|
|
|
require => Package['icinga2'],
|
|
|
|
notify => Service['icinga2']
|
|
|
|
}
|
|
|
|
|
2013-10-13 17:15:35 +02:00
|
|
|
exec { 'Enable Icinga 2 features':
|
|
|
|
command => 'i2enfeature statusdat; \
|
2013-10-13 20:33:36 +02:00
|
|
|
i2enfeature compat-log; \
|
|
|
|
i2enfeature command; \
|
|
|
|
i2enfeature ido-mysql;',
|
|
|
|
require => [ Package['icinga2'], Exec['populate-icinga2-ido-mysql-db'] ]
|
2013-10-13 17:15:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
file { "/etc/icinga2/features-enabled/*":
|
|
|
|
notify => Service['icinga2']
|
|
|
|
}
|
2013-10-13 20:33:36 +02:00
|
|
|
|
2013-10-13 21:53:11 +02:00
|
|
|
# populate icinga2-ido-mysql db
|
2013-10-13 20:33:36 +02:00
|
|
|
exec { 'populate-icinga2-ido-mysql-db':
|
|
|
|
unless => 'mysql -uicinga -picinga icinga -e "SELECT * FROM icinga_dbversion;" &> /dev/null',
|
|
|
|
command => 'mysql -uicinga -picinga icinga < /usr/share/doc/icinga2-ido-mysql-$(rpm -q icinga2-ido-mysql | cut -d\'-\' -f4)/schema/mysql.sql',
|
|
|
|
require => [ Package['icinga2-ido-mysql'], Exec['create-mysql-icinga2-ido-db'] ]
|
|
|
|
}
|
|
|
|
|
|
|
|
#exec { 'populate-icinga2-ido-pgsql-db':
|
|
|
|
# unless => 'psql -U icinga -d icinga -c "SELECT * FROM icinga_dbversion;" &> /dev/null',
|
|
|
|
# command => 'sudo -u postgres psql -U icinga -d icinga < /usr/share/doc/icinga2-ido-pgsql-$(rpm -q icinga2-ido-mysql | cut -d\'-\' -f4)/schema/pgsql.sql',
|
|
|
|
# require => [ Package['icinga2-ido-pgsql'], Exec['create-pgsql-icinga2-ido-db'] ]
|
|
|
|
#}
|
2013-10-13 17:15:35 +02:00
|
|
|
|
2013-10-14 14:12:32 +02:00
|
|
|
exec { 'populate-icinga-web-mysql-db':
|
|
|
|
unless => 'mysql -uicinga_web -picinga_web icinga_web -e "SELECT * FROM nsm_user;" &> /dev/null',
|
|
|
|
command => 'mysql -uicinga_web -picinga_web icinga_web < /usr/share/icinga-web/etc/schema/mysql.sql',
|
|
|
|
require => [ Package['icinga-web'], Exec['create-mysql-icinga-web-db'] ]
|
|
|
|
}
|
2013-10-13 17:15:35 +02:00
|
|
|
|