Merge branch 'feature/vagrant-log-and-icinga-pipe-writable-4549'

resolves #4549
This commit is contained in:
Jannis Moßhammer 2013-08-16 17:52:26 +02:00
commit 8407111c8a
9 changed files with 226 additions and 23 deletions

3
.gitignore vendored
View File

@ -1,9 +1,10 @@
# Exclude all hidden files
.*
# But not .gitignore, .vagrant-puppet and .htaccess
# But not .gitignore, .vagrant-puppet, .htaccess and .gitkeep
!.gitignore
!.vagrant-puppet
!public/.htaccess
!.gitkeep
build/
test/js/npm-debug.log

View File

@ -0,0 +1,71 @@
#!/bin/bash
#
# chkconfig: 345 99 01
#
### BEGIN INIT INFO
# Provides: icinga_command_proxy
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Should-Start: icinga
# Should-Stop: icinga
### END INIT INFO
# Source function library.
. /etc/rc.d/init.d/functions
PROG="icinga_command_proxy"
BIN="/usr/local/bin/icinga_command_proxy"
if [[ -f /etc/sysconfig/$PROG ]]; then
. /etc/sysconfig/$PROG
fi
ICINGA_CMD=${ICINGA_CMD:-"/usr/local/icinga/var/rw/icinga.cmd"}
ICINGA_MYSQL_CMD=${ICINGA_MYSQL_CMD:-"/usr/local/icinga-mysql/var/rw/icinga.cmd"}
ICINGA_PGSQL_CMD=${ICINGA_PGSQL_CMD:-"/usr/local/icinga-pgsql/var/rw/icinga.cmd"}
LOCKFILE=${LOCKFILE:-/var/lock/subsys/$PROG}
PIDFILE=${PIDFILE:-/var/lock/subsys/$PROG/$PROD.pid}
RETVAL=0
start() {
echo -n $"Starting $PROG: "
daemon --pidfile="$PIDFILE" "nohup \"$BIN\" \"$ICINGA_CMD\" \"$ICINGA_MYSQL_CMD\" \"$ICINGA_PGSQL_CMD\" >/dev/null 2>&1 &"
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch "$LOCKFILE"
return $RETVAL
}
stop() {
echo -n $"Stopping $PROG: "
killproc -p "$PIDFILE" "$BIN"
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f "$LOCKFILE" "$PIDFILE"
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p "$PIDFILE" "$BIN"
RETVAL=$?
;;
restart)
stop
start
;;
*)
echo $"Usage: $PROG {start|stop|restart|status}"
RETVAL=2
esac
exit $RETVAL

View File

@ -0,0 +1,42 @@
#!/bin/bash
#
# Redirect commands from pipe A to pipe B and C
#
set -e
set -u
ICINGA_CMD=${1:-"/usr/local/icinga/var/rw/icinga.cmd"}
ICINGA_MYSQL_CMD=${2:-"/usr/local/icinga-mysql/var/rw/icinga.cmd"}
ICINGA_PGSQL_CMD=${3:-"/usr/local/icinga-pgsql/var/rw/icinga.cmd"}
trap 'rm -f "$ICINGA_CMD"; exit' EXIT SIGKILL
if [[ -p "$ICINGA_CMD" ]]; then
rm -f "$ICINGA_CMD"
fi
mkfifo -m 660 "$ICINGA_CMD"
chown icinga.icinga-cmd "$ICINGA_CMD"
while true
do
if read COMMAND
then
if [[ -p "$ICINGA_MYSQL_CMD" ]]; then
echo "$COMMAND" > "$ICINGA_MYSQL_CMD"
else
logger -p local0.err Can\'t distribute command to the Icinga MySQL instance since its command pipe doesn\'t exist
fi
if [[ -p "$ICINGA_PGSQL_CMD" ]]; then
echo "$COMMAND" > "$ICINGA_PGSQL_CMD"
else
logger -p local0.err Can\'t distribute command to the Icinga PostgreSQL instance since its command pipe doesn\'t exist
fi
fi
done < "$ICINGA_CMD" 3> "$ICINGA_CMD"
# Reset all traps
trap - EXIT SIGKILL
exit 0

View File

@ -347,15 +347,10 @@ exec { 'install php-ZendFramework-Db-Adapter-Pdo-Mysql':
require => Exec['install ZendFramework']
}
file { ['/etc/icinga2-web/',
'/etc/icinga2-web/enabledModules/']:
ensure => 'directory',
owner => 'apache',
group => 'apache'
}
file { '/etc/motd':
source => 'puppet:////vagrant/.vagrant-puppet/files/etc/motd'
source => 'puppet:////vagrant/.vagrant-puppet/files/etc/motd',
owner => root,
group => root
}
user { 'vagrant':
@ -454,3 +449,77 @@ 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-accounts':
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-accounts':
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'] ]
}
exec { 'populate-icingaweb-mysql-db-preferences':
unless => 'mysql -uicingaweb -picinga icingaweb -e "SELECT * FROM preference;" &> /dev/null',
command => 'mysql -uicingaweb -picinga icingaweb < /vagrant/etc/schema/preferences.mysql.sql',
require => [ Exec['create-mysql-icingaweb-db'] ]
}
exec { 'populate-icingweba-pgsql-db-preferences':
unless => 'psql -U icingaweb -d icingaweb -c "SELECT * FROM preference;" &> /dev/null',
command => 'sudo -u postgres psql -U icingaweb -d icingaweb -f /vagrant/etc/schema/preferences.pgsql.sql',
require => [ Exec['create-pgsql-icingaweb-db'] ]
}
#
# Following section creates the Icinga command proxy to /usr/local/icinga-mysql/var/rw/icinga.cmd (which is the
# config's default path for the Icinga command pipe) in order to send commands to both the MySQL and PostgreSQL instance
#
file { [ '/usr/local/icinga/', '/usr/local/icinga/var/', '/usr/local/icinga/var/rw/' ]:
ensure => directory,
owner => icinga,
group => icinga,
require => User['icinga']
}
file { '/usr/local/bin/icinga_command_proxy':
source => 'puppet:////vagrant/.vagrant-puppet/files/usr/local/bin/icinga_command_proxy',
owner => root,
group => root,
mode => 755
}
file { '/etc/init.d/icinga_command_proxy':
source => 'puppet:////vagrant/.vagrant-puppet/files/etc/init.d/icinga_command_proxy',
owner => root,
group => root,
mode => 755,
require => File['/usr/local/bin/icinga_command_proxy']
}
service { 'icinga_command_proxy':
ensure => running,
require => [ File['/etc/init.d/icinga_command_proxy'], Service['icinga-mysql'], Service['icinga-pgsql'] ]
}

View File

@ -11,8 +11,8 @@ installJquery () {
}
mountIcinga2webConfd () {
# Remount /vagrant/config with appropriate permissions since the group apache is missing initially
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g apache`,dmode=775,fmode=775 /vagrant/config /vagrant/config
# Remount /vagrant/config/ with appropriate permissions since the group apache is missing initially
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g apache`,dmode=775,fmode=775 /vagrant/config/ /vagrant/config/
}
startServicesWithNonLSBCompliantExitStatusCodes () {
@ -21,8 +21,14 @@ startServicesWithNonLSBCompliantExitStatusCodes () {
service ido2db-pgsql start || true
}
mountIcinga2webVarLog () {
# Remount /vagrant/var/log/ with appropriate permissions since the group apache is missing initially
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g apache`,dmode=775,fmode=775 /vagrant/var/log/ /vagrant/var/log/
}
installJquery
mountIcinga2webConfd
startServicesWithNonLSBCompliantExitStatusCodes
mountIcinga2webVarLog
exit 0

View File

@ -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:

View File

@ -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.
@ -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.

1
Vagrantfile vendored
View File

@ -42,6 +42,7 @@ Vagrant.configure("2") do |config|
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
config.vm.synced_folder "./config", "/vagrant/config"
config.vm.synced_folder "./var/log", "/vagrant/var/log"
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.

0
var/log/.gitkeep Normal file
View File