From fc370f7801116c8503aeaa56159fc4f5645ee391 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 3 Jun 2013 17:54:44 +0200 Subject: [PATCH] Vagrant/Icinga w/ MySQL: Add proper apache configuration Icinga with IDOUtils running on a MySQL database is now available via /icinga-mysql refs #4216 --- .vagrant-puppet/manifests/default.pp | 41 ++++++++++++++----- .../modules/apache/manifests/init.pp | 1 + .../modules/cmmi/manifests/init.pp | 2 +- .vagrant-puppet/modules/php/manifests/init.pp | 2 +- README.md | 33 ++++++++++++--- 5 files changed, 61 insertions(+), 18 deletions(-) diff --git a/.vagrant-puppet/manifests/default.pp b/.vagrant-puppet/manifests/default.pp index f627664b2..28abe47a1 100644 --- a/.vagrant-puppet/manifests/default.pp +++ b/.vagrant-puppet/manifests/default.pp @@ -1,7 +1,7 @@ include apache -include php include mysql include pgsql +include php Exec { path => '/bin:/usr/bin:/sbin' } @@ -10,7 +10,7 @@ exec { 'create-mysql-icinga-db': command => 'mysql -uroot -e "CREATE DATABASE icinga; \ GRANT ALL ON icinga.* TO icinga@localhost \ IDENTIFIED BY \'icinga\';"', - require => Service['mysqld'], + require => Service['mysqld'] } exec{ 'create-pgsql-icinga-db': @@ -25,9 +25,9 @@ $icinga_packages = [ 'gcc', 'glibc', 'glibc-common', 'gd', 'gd-devel', 'libdbi-dbd-mysql', 'libdbi-dbd-pgsql' ] package { $icinga_packages: ensure => installed } + group { 'icinga-cmd': - ensure => present, - members => 'www-data' + ensure => present } user { 'icinga': @@ -36,13 +36,23 @@ user { 'icinga': managehome => false } +user { 'apache': + groups => 'icinga-cmd', + require => [Package["${apache::apache}"], Group['icinga-cmd']] +} + cmmi { 'icinga-mysql': url => 'http://sourceforge.net/projects/icinga/files/icinga/1.9.1/icinga-1.9.1.tar.gz/download', output => 'icinga-1.9.1.tar.gz', flags => '--prefix=/usr/local/icinga-mysql --with-command-group=icinga-cmd \ - --enable-idoutils --with-init-dir=/tmp/icinga-mysql/etc/init.d', + --enable-idoutils --with-init-dir=/tmp/icinga-mysql/etc/init.d \ + --with-htmurl=/icinga-mysql --with-httpd-conf-file=/etc/httpd/conf.d/icinga-mysql.conf \ + --with-cgiurl=/icinga-mysql/cgi-bin \ + --with-http-auth-file=/usr/share/icinga/htpasswd.users', creates => '/usr/local/icinga-mysql', - require => User['icinga'] + make => 'make all && make fullinstall install-config', + require => User['icinga'], + notify => Service["${apache::apache}"] } file { '/etc/init.d/icinga-mysql': @@ -60,9 +70,14 @@ cmmi { 'icinga-pgsql': output => 'icinga-1.9.1.tar.gz', flags => '--prefix=/usr/local/icinga-pgsql \ --with-command-group=icinga-cmd --enable-idoutils \ - --with-init-dir=/tmp/icinga-pgsql/etc/init.d', + --with-init-dir=/tmp/icinga-pgsql/etc/init.d \ + --with-htmurl=/icinga-pgsql --with-httpd-conf-file=/etc/httpd/conf.d/icinga-pgsql.conf \ + --with-cgiurl=/icinga-pgsql/cgi-bin \ + --with-http-auth-file=/usr/share/icinga/htpasswd.users', creates => '/usr/local/icinga-pgsql', - require => User['icinga'] + make => 'make all && make install install-base install-cgis install-html install-init install-commandmode install-idoutils install-config', + require => User['icinga'], + notify => Service["${apache::apache}"] } file { '/etc/init.d/icinga-pgsql': @@ -76,13 +91,13 @@ file { '/etc/init.d/ido2db-pgsql': } exec { 'populate-icinga-mysql-db': - unless => 'mysql -uicinga -picinga icinga -e "SELECT * FROM icinga_dbversion;" > /dev/null', + unless => 'mysql -uicinga -picinga icinga -e "SELECT * FROM icinga_dbversion;" &> /dev/null', command => 'mysql -uicinga -picinga icinga < /usr/local/src/icinga-mysql/icinga-1.9.1/module/idoutils/db/mysql/mysql.sql', require => [Cmmi['icinga-mysql'], Exec['create-mysql-icinga-db']] } exec { 'populate-icinga-pgsql-db': - unless => 'psql -U icinga -d icinga -c "SELECT * FROM icinga_dbversion;" > /dev/null', + unless => 'psql -U icinga -d icinga -c "SELECT * FROM icinga_dbversion;" &> /dev/null', command => 'sudo -u postgres psql -U icinga -d icinga < /usr/local/src/icinga-pgsql/icinga-1.9.1/module/idoutils/db/pgsql/pgsql.sql', require => [Cmmi['icinga-pgsql'], Exec['create-pgsql-icinga-db']] } @@ -159,3 +174,9 @@ exec { 'iptables-allow-http': unless => 'grep -Fxqe "-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT" /etc/sysconfig/iptables', command => 'iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT && iptables-save > /etc/sysconfig/iptables' } + +exec { 'icinga-htpasswd': + creates => '/usr/share/icinga/htpasswd.users', + command => 'mkdir /usr/share/icinga && htpasswd -b -c /usr/share/icinga/htpasswd.users icingaadmin icinga', + require => Package["${apache::apache}"] +} diff --git a/.vagrant-puppet/modules/apache/manifests/init.pp b/.vagrant-puppet/modules/apache/manifests/init.pp index a9ce981fd..e328ff95f 100644 --- a/.vagrant-puppet/modules/apache/manifests/init.pp +++ b/.vagrant-puppet/modules/apache/manifests/init.pp @@ -26,6 +26,7 @@ class apache { service { $apache: ensure => running, + alias => 'apache', require => Package['apache'] } } diff --git a/.vagrant-puppet/modules/cmmi/manifests/init.pp b/.vagrant-puppet/modules/cmmi/manifests/init.pp index eb6d43cbe..f8f224a89 100644 --- a/.vagrant-puppet/modules/cmmi/manifests/init.pp +++ b/.vagrant-puppet/modules/cmmi/manifests/init.pp @@ -31,7 +31,7 @@ define cmmi( $output, $flags, $creates, - $make='make all && make fullinstall && make install-config', + $make='make all && make install', ) { Exec { path => '/bin:/usr/bin' } diff --git a/.vagrant-puppet/modules/php/manifests/init.pp b/.vagrant-puppet/modules/php/manifests/init.pp index 4cce68676..b7822184c 100644 --- a/.vagrant-puppet/modules/php/manifests/init.pp +++ b/.vagrant-puppet/modules/php/manifests/init.pp @@ -15,7 +15,7 @@ class php { package { 'php': - ensure => installed, + ensure => installed, require => Package["${apache::apache}"] } diff --git a/README.md b/README.md index f597fe5b2..66bc64bfc 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ After you should be able to browse [localhost:8080/icinga2-web](http://localhost #### Environment -Forwarded ports: +**Forwarded ports**: @@ -38,19 +38,40 @@ Forwarded ports:
-Installed packages: +**Installed packages**: * Apache2 with PHP library * PHP with MySQL libray * MySQL server and client software * PostgreSQL server and client software +* [Icinga prerequisites](http://docs.icinga.org/latest/en/quickstart-idoutils.html#installpackages) -Installed users and groups: +**Installed users and groups**: * User icinga with group icinga and icinga-cmd * Webserver user added to group icinga-cmd -Installed software: +**Installed files**: -* Icinga with IDOUtils using a MySQL database -* Icinga with IDOUtils using a PostgreSQL database +* `/usr/share/icinga/htpasswd.users` account information for logging into the Icinga classic web interface for both instances + +**Installed software**: + +* Icinga 1.9.1 with IDOUtils using a MySQL database +* Icinga 1.9.1 with IDOUtils using a PostgreSQL database + +##### Icinga with IDOUtils using a MySQL database + +**Installation path**: `/usr/local/icinga-mysql` + +**Services**: + +* `icinga-mysql` +* `ido2db-mysql` + +Connect to the **icinga mysql database** using the following command: + + mysql -u icinga -p icinga icinga + +Access the **Classic UI** (CGIs) via [localhost:8080/icinga-mysql](http://localhost:8080/icinga-mysql). +For logging into the Icinga classic web interface use user *icingaadmin* with password *icinga*.