2014-12-10 16:01:54 +01:00
|
|
|
class icingaweb2_dev (
|
2015-01-19 11:43:13 +01:00
|
|
|
$config = hiera('icingaweb2::config'),
|
|
|
|
$log = hiera('icingaweb2::log'),
|
|
|
|
$web_path = hiera('icingaweb2::web_path'),
|
|
|
|
$db_user = hiera('icingaweb2::db_user'),
|
|
|
|
$db_pass = hiera('icingaweb2::db_pass'),
|
|
|
|
$db_name = hiera('icingaweb2::db_name'),
|
|
|
|
$web_group = hiera('icingaweb2::group'),
|
2014-12-10 16:01:54 +01:00
|
|
|
) {
|
2014-09-10 11:45:57 +02:00
|
|
|
include apache
|
2014-09-10 18:27:27 +02:00
|
|
|
include php
|
2015-01-20 10:07:27 +01:00
|
|
|
include php_imagick
|
2014-12-10 16:01:54 +01:00
|
|
|
include icingaweb2::config
|
2014-09-15 14:42:54 +02:00
|
|
|
include icingacli
|
2014-11-24 14:44:17 +01:00
|
|
|
include icinga_packages
|
2014-11-25 17:46:29 +01:00
|
|
|
include openldap
|
2014-09-11 11:30:24 +02:00
|
|
|
|
2014-12-10 16:01:54 +01:00
|
|
|
# TODO(el): Only include zend_framework. Apache does not have to be notified
|
2014-09-11 11:30:24 +02:00
|
|
|
class { 'zend_framework':
|
|
|
|
notify => Service['apache'],
|
|
|
|
}
|
2014-09-10 11:45:57 +02:00
|
|
|
|
2014-12-10 16:01:54 +01:00
|
|
|
# TODO(el): icinga-gui is not a icingaweb2_dev package
|
2015-01-20 12:54:14 +01:00
|
|
|
package { [ 'php-gd', 'php-intl', 'php-pdo', 'php-ldap', 'php-phpunit-PHPUnit', 'icinga-gui' ]:
|
2014-09-11 11:17:51 +02:00
|
|
|
ensure => latest,
|
|
|
|
notify => Service['apache'],
|
2014-11-24 14:44:17 +01:00
|
|
|
require => Class['icinga_packages'],
|
2014-09-11 11:17:51 +02:00
|
|
|
}
|
|
|
|
|
2014-09-15 14:42:54 +02:00
|
|
|
Exec { path => '/usr/local/bin:/usr/bin:/bin' }
|
2014-09-15 13:35:14 +02:00
|
|
|
|
2014-12-10 16:01:54 +01:00
|
|
|
# TODO(el): Enabling/disabling modules should be a resource
|
2015-01-19 11:43:13 +01:00
|
|
|
User <| alias == apache |> { groups +> $web_group }
|
2014-09-15 13:35:14 +02:00
|
|
|
-> exec { 'enable-monitoring-module':
|
2014-09-11 11:53:20 +02:00
|
|
|
command => 'icingacli module enable monitoring',
|
2014-09-15 14:20:13 +02:00
|
|
|
user => 'apache',
|
2014-09-15 14:42:54 +02:00
|
|
|
require => Class[[ 'icingacli', 'apache' ]],
|
2014-09-11 11:53:20 +02:00
|
|
|
}
|
2014-10-30 17:03:09 +01:00
|
|
|
-> exec { 'enable-test-module':
|
|
|
|
command => 'icingacli module enable test',
|
|
|
|
user => 'apache'
|
|
|
|
}
|
2014-09-11 11:53:20 +02:00
|
|
|
|
2014-12-10 16:01:54 +01:00
|
|
|
# TODO(el): 'icingacmd' is NOT a icingaweb2_dev group
|
2014-09-15 16:17:04 +02:00
|
|
|
group { 'icingacmd':
|
|
|
|
ensure => present,
|
|
|
|
}
|
2014-09-12 19:03:17 +02:00
|
|
|
|
2014-12-10 16:01:54 +01:00
|
|
|
User <| alias == apache |> { groups +> 'icingacmd' }
|
|
|
|
|
2014-12-15 11:44:19 +01:00
|
|
|
$log_dir = inline_template('<%= File.dirname(@log) %>')
|
|
|
|
file { $log_dir:
|
2014-12-10 16:01:54 +01:00
|
|
|
ensure => directory,
|
|
|
|
owner => 'root',
|
2015-01-19 11:43:13 +01:00
|
|
|
group => $web_group,
|
2014-12-10 16:01:54 +01:00
|
|
|
mode => '2775'
|
2014-09-15 16:17:04 +02:00
|
|
|
}
|
|
|
|
|
2014-11-26 12:32:22 +01:00
|
|
|
$icingaadminSelect = "as CNT from icingaweb_user where name = \'icingaadmin\'\" |grep -qwe \'cnt=0\'"
|
|
|
|
$icingaadminInsert = "\"INSERT INTO icingaweb_user (name, active, password_hash) VALUES (\'icingaadmin\', 1, \'\\\$1\\\$JMdnEc9M\\\$FW7yapAjv0atS43NkapGo/\');\""
|
|
|
|
|
2014-12-10 16:01:54 +01:00
|
|
|
mysql::database::populate { "${db_name}":
|
|
|
|
username => "${db_user}",
|
|
|
|
password => "${db_pass}",
|
2014-08-06 13:27:16 +02:00
|
|
|
privileges => 'ALL',
|
2014-11-25 12:55:51 +01:00
|
|
|
schemafile => '/vagrant/etc/schema/mysql.schema.sql',
|
2014-08-06 13:27:16 +02:00
|
|
|
}
|
2014-11-26 12:32:22 +01:00
|
|
|
-> exec { 'mysql-icingaadmin':
|
2014-12-10 16:01:54 +01:00
|
|
|
onlyif => "mysql -u${db_user} -p${db_pass} ${db_name} -e \"select CONCAT(\'cnt=\', COUNT(name)) ${icingaadminSelect}",
|
|
|
|
command => "mysql -u${db_user} -p${db_pass} ${db_name} -e ${icingaadminInsert}",
|
2014-11-26 12:32:22 +01:00
|
|
|
}
|
2014-08-06 13:27:16 +02:00
|
|
|
|
2014-12-10 16:01:54 +01:00
|
|
|
pgsql::database::populate { "${db_name}":
|
|
|
|
username => "${db_user}",
|
|
|
|
password => "${db_pass}",
|
2014-11-25 12:55:51 +01:00
|
|
|
schemafile => '/vagrant/etc/schema/pgsql.schema.sql',
|
2014-08-06 13:27:16 +02:00
|
|
|
}
|
2014-11-26 12:32:22 +01:00
|
|
|
-> exec { 'pgsql-icingaadmin':
|
2014-12-10 16:01:54 +01:00
|
|
|
onlyif => "psql -U ${db_user} -w -d ${db_name} -c \"select 'cnt=' || COUNT(name) ${icingaadminSelect}",
|
|
|
|
command => "psql -U ${db_user} -w -d ${db_name} -c ${icingaadminInsert}",
|
|
|
|
environment => "PGPASSWORD=${db_pass}",
|
2014-11-26 12:32:22 +01:00
|
|
|
}
|
2014-08-06 13:27:16 +02:00
|
|
|
|
|
|
|
file { '/etc/httpd/conf.d/icingaweb.conf':
|
2014-12-15 10:51:59 +01:00
|
|
|
content => template("$name/icingaweb.conf.erb"),
|
2014-08-06 13:27:16 +02:00
|
|
|
notify => Service['apache'],
|
|
|
|
}
|
|
|
|
|
2014-09-10 11:21:29 +02:00
|
|
|
icingaweb2::config::general { 'authentication':
|
2014-12-15 10:26:40 +01:00
|
|
|
source => $name,
|
2015-10-21 15:45:36 +02:00
|
|
|
replace => false,
|
2014-09-09 16:27:26 +02:00
|
|
|
}
|
2014-08-06 13:27:16 +02:00
|
|
|
|
2015-03-05 14:13:23 +01:00
|
|
|
icingaweb2::config::general { [ 'config', 'resources', 'roles' ]:
|
2014-12-15 10:26:40 +01:00
|
|
|
source => $name,
|
2014-09-09 15:15:53 +02:00
|
|
|
replace => false,
|
2014-08-22 11:37:46 +02:00
|
|
|
}
|
|
|
|
|
2014-09-09 16:27:26 +02:00
|
|
|
icingaweb2::config::module { [ 'backends', 'config', 'instances' ]:
|
2014-12-10 16:01:54 +01:00
|
|
|
module => 'monitoring',
|
2014-09-09 16:27:26 +02:00
|
|
|
source => 'puppet:///modules/icingaweb2_dev',
|
|
|
|
}
|
2014-09-30 10:59:30 +02:00
|
|
|
|
2014-12-10 16:01:54 +01:00
|
|
|
# TODO(el): Should be a resource
|
2014-09-30 10:59:30 +02:00
|
|
|
package { 'iptables':
|
|
|
|
ensure => latest
|
|
|
|
}
|
|
|
|
-> exec { 'iptables-allow-http':
|
2014-12-10 16:01:54 +01:00
|
|
|
unless => 'grep -qe "-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT" /etc/sysconfig/iptables',
|
2014-10-21 12:22:17 +02:00
|
|
|
command => '/sbin/iptables -I INPUT 1 -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT && /sbin/iptables-save > /etc/sysconfig/iptables'
|
2014-09-30 10:59:30 +02:00
|
|
|
}
|
2014-11-25 17:46:29 +01:00
|
|
|
|
2014-12-10 16:01:54 +01:00
|
|
|
# TODO(el): Don't define inside a class
|
2014-11-25 17:46:29 +01:00
|
|
|
define openldap_file {
|
|
|
|
file { "openldap/${name}.ldif":
|
|
|
|
path => "/usr/share/openldap-servers/${name}.ldif",
|
|
|
|
source => "puppet:///modules/icingaweb2_dev/openldap/${name}.ldif",
|
|
|
|
require => Class['openldap'],
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
openldap_file { [ 'db', 'dit', 'users' ]: }
|
|
|
|
|
|
|
|
exec { 'populate-openldap':
|
2014-12-10 16:01:54 +01:00
|
|
|
# TODO(el): Split the command and use unless instead of trying to populate openldap everytime
|
2014-11-25 17:46:29 +01:00
|
|
|
command => 'sudo ldapadd -c -Y EXTERNAL -H ldapi:/// -f /usr/share/openldap-servers/db.ldif || true && \
|
|
|
|
sudo ldapadd -c -D cn=admin,dc=icinga,dc=org -x -w admin -f /usr/share/openldap-servers/dit.ldif || true && \
|
|
|
|
sudo ldapadd -c -D cn=admin,dc=icinga,dc=org -x -w admin -f /usr/share/openldap-servers/users.ldif || true',
|
|
|
|
require => [
|
|
|
|
Service['slapd'],
|
|
|
|
File[[
|
|
|
|
'openldap/db.ldif',
|
|
|
|
'openldap/dit.ldif',
|
|
|
|
'openldap/users.ldif'
|
|
|
|
]]
|
|
|
|
],
|
|
|
|
}
|
2014-11-26 14:03:04 +01:00
|
|
|
|
2014-12-10 16:01:54 +01:00
|
|
|
# TODO(el): Should be a module
|
2014-11-26 14:03:04 +01:00
|
|
|
package { 'php-deepend-Mockery':
|
|
|
|
ensure => latest,
|
|
|
|
}
|
2014-08-06 13:27:16 +02:00
|
|
|
}
|