From 9b203ce698db68363e1e5468721ad1bc54a2fb4c Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 14 Aug 2013 17:37:17 +0200 Subject: [PATCH] Vagrant: Create and populate Icinga 2 Web MySQL and PostgreSQL databases refs #4464 --- .vagrant-puppet/manifests/default.pp | 32 +++++++++++++++++++ .../modules/pgsql/templates/pg_hba.conf.erb | 5 +++ README.md | 32 ++++++++++++------- 3 files changed, 57 insertions(+), 12 deletions(-) diff --git a/.vagrant-puppet/manifests/default.pp b/.vagrant-puppet/manifests/default.pp index e83d88a75..27cb4984a 100644 --- a/.vagrant-puppet/manifests/default.pp +++ b/.vagrant-puppet/manifests/default.pp @@ -454,3 +454,35 @@ populate_monitoring_test_config_plugins{ ['test_hostcheck.pl', 'test_servicechec Cmmi['icinga-mysql'], Cmmi['icinga-pgsql'] ] } + + +# +# Following section creates and populates MySQL and PostgreSQL Icinga 2 Web databases +# +exec { 'create-mysql-icingaweb-db': + unless => 'mysql -uicingaweb -picinga icingaweb', + command => 'mysql -uroot -e "CREATE DATABASE icingaweb; \ + GRANT ALL ON icingaweb.* TO icingaweb@localhost \ + IDENTIFIED BY \'icinga\';"', + require => Service['mysqld'] +} + +exec{ 'create-pgsql-icingaweb-db': + unless => 'sudo -u postgres psql -tAc "SELECT 1 FROM pg_roles WHERE rolname=\'icingaweb\'" | grep -q 1', + command => 'sudo -u postgres psql -c "CREATE ROLE icingaweb WITH LOGIN PASSWORD \'icinga\';" && \ + sudo -u postgres createdb -O icingaweb -E UTF8 icingaweb && \ + sudo -u postgres createlang plpgsql icingaweb', + require => Service['postgresql'] +} + +exec { 'populate-icingaweb-mysql-db': + unless => 'mysql -uicingaweb -picinga icingaweb -e "SELECT * FROM account;" &> /dev/null', + command => 'mysql -uicingaweb -picinga icingaweb < /vagrant/etc/schema/users.mysql.sql', + require => [ Exec['create-mysql-icingaweb-db'] ] +} + +exec { 'populate-icingweba-pgsql-db': + unless => 'psql -U icingaweb -d icingaweb -c "SELECT * FROM account;" &> /dev/null', + command => 'sudo -u postgres psql -U icingaweb -d icingaweb -f /vagrant/etc/schema/users.pgsql.sql', + require => [ Exec['create-pgsql-icingaweb-db'] ] +} diff --git a/.vagrant-puppet/modules/pgsql/templates/pg_hba.conf.erb b/.vagrant-puppet/modules/pgsql/templates/pg_hba.conf.erb index b4d3f81bf..f6fb19ebf 100644 --- a/.vagrant-puppet/modules/pgsql/templates/pg_hba.conf.erb +++ b/.vagrant-puppet/modules/pgsql/templates/pg_hba.conf.erb @@ -76,6 +76,11 @@ local icinga_unittest icinga_unittest trust host icinga_unittest icinga_unittest 127.0.0.1/32 trust host icinga_unittest icinga_unittest ::1/128 trust +# icingaweb +local icingaweb icingaweb trust +host icingaweb icingaweb 127.0.0.1/32 trust +host icingaweb icingaweb ::1/128 trust + # "local" is for Unix domain socket connections only local all all ident # IPv4 local connections: diff --git a/README.md b/README.md index 89032e17d..0ff85237f 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,6 @@ ## Vagrant - > **Note** that the deployment of the virtual machine is tested against Vagrant starting with version 1.1. > Unfortunately older versions will not work. @@ -24,7 +23,7 @@ have to do is install Vagrant and run: After you should be able to browse [localhost:8080/icinga2-web](http://localhost:8080/icinga2-web). -### Environment +### Environment **Forwarded ports**: @@ -113,7 +112,7 @@ Configuration can be adjusted and recreated with **/usr/local/share/misc/monitor vagrant provision -in the host after any modification to the script just mentioned. +in the host after any modification to the script just mentioned. #### MK Livestatus @@ -151,30 +150,30 @@ Examples to query our database instance: This is what the **dc=icinga,dc=org** *DIT* looks like: > dn: dc=icinga,dc=org -> +> > dn: ou=people,dc=icinga,dc=org -> +> > dn: ou=groups,dc=icinga,dc=org -> +> > dn: cn=Users,ou=groups,dc=icinga,dc=org > cn: Users > uniqueMember: cn=Jon Doe,ou=people,dc=icinga,dc=org > uniqueMember: cn=Jane Smith,ou=people,dc=icinga,dc=org > uniqueMember: cn=John Q. Public,ou=people,dc=icinga,dc=org > uniqueMember: cn=Richard Roe,ou=people,dc=icinga,dc=org -> +> > dn: cn=John Doe,ou=people,dc=icinga,dc=org > cn: John Doe > uid: jdoe -> +> > dn: cn=Jane Smith,ou=people,dc=icinga,dc=org > cn: Jane Smith > uid: jsmith -> +> > dn: cn=John Q. Public,ou=people,dc=icinga,dc=org > cn: John Q. Public > uid: jqpublic -> +> > dn: cn=Richard Roe,ou=people,dc=icinga,dc=org > cn: Richard Roe > uid: rroe @@ -183,9 +182,9 @@ All users share the password `password`. #### Testing the code -All software required to run tests is installed in the virtual machine. +All software required to run tests is installed in the virtual machine. In order to run all tests you have to execute the following commands: - + vagrant ssh -c /vagrant/test/php/runtests vagrant ssh -c /vagrant/test/php/checkswag vagrant ssh -c /vagrant/test/js/runtests @@ -203,3 +202,12 @@ code style issues. cd /usr/local/icinga2 ./sbin/icinga2 -c etc/icinga2/icinga2.conf.dist + +## Log into Icinga 2 Web + +If you've configure LDAP as authentication backend (which is the default) use the following login credentials: + +> **Username**: jdoe +> **Password**: password + +Have a look at [LDAP example data](#ldap example data) for more accounts.