diff --git a/.gitattributes b/.gitattributes index 35002d0cb..40b06093e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,4 +2,4 @@ .git* export-ignore # Normalize puppet manifests' line endings to LF on checkin and prevent conversion to CRLF when the files are checked out -.vagrant-puppet/* eol=lf +.puppet* eol=lf diff --git a/.gitignore b/.gitignore index 3cc377b8d..6c60b5fbb 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,7 @@ # Except those related to git and vagrant !.git* -!.vagrant-puppet/* +!.puppet* # Exclude application log files var/log/* diff --git a/.puppet/TODO.md b/.puppet/TODO.md new file mode 100644 index 000000000..04af9a108 --- /dev/null +++ b/.puppet/TODO.md @@ -0,0 +1,22 @@ +Fix steps that are always provisioned: + +==> default: Notice: /Stage[main]/Icinga2/Icinga2::Feature[statusdata]/Parent_dirs[/etc/icinga2/features-enabled/statusdata.conf]/Exec[parent_dirs-/etc/icinga2/features-enabled/statusdata.conf]/returns: executed successfully +==> default: Notice: /Stage[main]/Icinga2_dev/Icinga2::Config[constants]/Parent_dirs[/etc/icinga2/constants.conf]/Exec[parent_dirs-/etc/icinga2/constants.conf]/returns: executed successfully +==> default: Notice: /Stage[main]/Icinga2_dev/Icinga2::Config[conf.d/commands]/Parent_dirs[/etc/icinga2/conf.d/commands.conf]/Exec[parent_dirs-/etc/icinga2/conf.d/commands.conf]/returns: executed successfully +==> default: Notice: /Stage[main]/Icinga2/Icinga2::Feature[command]/Parent_dirs[/etc/icinga2/features-enabled/command.conf]/Exec[parent_dirs-/etc/icinga2/features-enabled/command.conf]/returns: executed successfully +==> default: Notice: /Stage[main]/Icingaweb2_dev/Pgsql::Database::Populate[icingaweb]/Exec[populate-icingaweb-pgsql-db]/returns: executed successfully +==> default: Notice: /Stage[main]/Php/Exec[php-timezone]/returns: executed successfully +==> default: Notice: /Stage[main]/Icinga2_dev/Icinga2::Config[conf.d/test-config]/Parent_dirs[/etc/icinga2/conf.d/test-config.conf]/Exec[parent_dirs-/etc/icinga2/conf.d/test-config.conf]/returns: executed successfully +==> default: Notice: /Stage[main]/Icingaweb2_dev/Exec[populate-openldap]/returns: executed successfully +==> default: Notice: /Stage[main]/Monitoring_test_config/Git_cmmi[Monitoring-Generator-TestConfig]/Cmmi_dir[Monitoring-Generator-TestConfig]/Exec[configure-Monitoring-Generator-TestConfig]/returns: executed successfully +==> default: Notice: /Stage[main]/Monitoring_test_config/Git_cmmi[Monitoring-Generator-TestConfig]/Cmmi_dir[Monitoring-Generator-TestConfig]/Exec[make-Monitoring-Generator-TestConfig]/returns: executed successfully +==> default: Notice: /Stage[main]/Icinga2/Icinga2::Feature[compatlog]/Parent_dirs[/etc/icinga2/features-enabled/compatlog.conf]/Exec[parent_dirs-/etc/icinga2/features-enabled/compatlog.conf]/returns: executed successfully +==> default: Notice: /Stage[main]/Icinga2_mysql/Icinga2::Feature[ido-mysql]/Parent_dirs[/etc/icinga2/features-enabled/ido-mysql.conf]/Exec[parent_dirs-/etc/icinga2/features-enabled/ido-mysql.conf]/returns: executed successfully +==> default: Notice: /Stage[main]/Apache/Service[httpd]: Triggered 'refresh' from 1 events +==> default: Notice: /Stage[main]/Icingaweb2_dev/Exec[enable-monitoring-module]/returns: executed successfully +==> default: Notice: /Stage[main]/Icingaweb2_dev/Exec[enable-test-module]/returns: executed successfully +==> default: Notice: /Stage[main]/Icinga2_mysql/Icinga2::Feature[ido-mysql]/Icinga2::Config[features-available/ido-mysql]/Parent_dirs[/etc/icinga2/features-available/ido-mysql.conf]/Exec[parent_dirs-/etc/icinga2/features-available/ido-mysql.conf]/returns: executed successfully +==> default: Notice: /Stage[main]/Icinga2_pgsql/Icinga2::Feature[ido-pgsql]/Icinga2::Config[features-available/ido-pgsql]/Parent_dirs[/etc/icinga2/features-available/ido-pgsql.conf]/Exec[parent_dirs-/etc/icinga2/features-available/ido-pgsql.conf]/returns: executed successfully +==> default: Notice: /Stage[main]/Icinga2_pgsql/Icinga2::Feature[ido-pgsql]/Parent_dirs[/etc/icinga2/features-enabled/ido-pgsql.conf]/Exec[parent_dirs-/etc/icinga2/features-enabled/ido-pgsql.conf]/returns: executed successfully + +Fix provisioning for CentOS 7 diff --git a/.vagrant-puppet/files/etc/profile.d/env.sh b/.puppet/files/etc/profile.d/env.sh similarity index 100% rename from .vagrant-puppet/files/etc/profile.d/env.sh rename to .puppet/files/etc/profile.d/env.sh diff --git a/.puppet/hiera/common.yaml b/.puppet/hiera/common.yaml new file mode 100644 index 000000000..c76b904bf --- /dev/null +++ b/.puppet/hiera/common.yaml @@ -0,0 +1,7 @@ +--- +icingaweb2::config: /etc/icingaweb2 +icingaweb2::log: /var/log/icingaweb2/icingaweb2.log +icingaweb2::web_path: icingaweb2 +icingaweb2::db_user: icingaweb2 +icingaweb2::db_pass: icingaweb2 +icingaweb2::db_name: icingaweb2 diff --git a/.puppet/hiera/hiera.yaml b/.puppet/hiera/hiera.yaml new file mode 100644 index 000000000..22012bbd7 --- /dev/null +++ b/.puppet/hiera/hiera.yaml @@ -0,0 +1,9 @@ +--- +:backends: + - yaml + +:hierarchy: + - common + +:yaml: + :datadir: /vagrant/.puppet/hiera diff --git a/.puppet/manifests/puppet.sh b/.puppet/manifests/puppet.sh new file mode 100644 index 000000000..225ce7398 --- /dev/null +++ b/.puppet/manifests/puppet.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +set -e + +if which puppet >/dev/null 2>&1; then + exit 0 +fi + +RELEASEVER=$(rpm -q --qf "%{VERSION}" $(rpm -q --whatprovides redhat-release)) + +case $RELEASEVER in + 6|7) + PUPPET="http://yum.puppetlabs.com/puppetlabs-release-el-${RELEASEVER}.noarch.rpm" + ;; + *) + echo "Unknown release version: $RELEASEVER" >&2 + exit 1 + ;; +esac + +echo "Adding puppet repository.." +rpm --import "https://yum.puppetlabs.com/RPM-GPG-KEY-puppetlabs" +rpm -ivh $PUPPET >/dev/null + +echo "Installing puppet.." +yum install -y puppet >/dev/null diff --git a/.puppet/manifests/site.pp b/.puppet/manifests/site.pp new file mode 100644 index 000000000..08120d911 --- /dev/null +++ b/.puppet/manifests/site.pp @@ -0,0 +1,17 @@ +stage { 'repositories': + before => Stage['main'], +} + +node default { + class { 'epel': + stage => repositories, + } + include icinga2_dev + include icingaweb2_dev + include motd + file { '/etc/profile.d/env.sh': + source => 'puppet:////vagrant/.puppet/files/etc/profile.d/env.sh' + } + @user { vagrant: ensure => present } + User <| title == vagrant |> { groups +> icingaweb } +} diff --git a/.vagrant-puppet/modules/apache/manifests/init.pp b/.puppet/modules/apache/manifests/init.pp similarity index 56% rename from .vagrant-puppet/modules/apache/manifests/init.pp rename to .puppet/modules/apache/manifests/init.pp index e328ff95f..e96150f12 100644 --- a/.vagrant-puppet/modules/apache/manifests/init.pp +++ b/.puppet/modules/apache/manifests/init.pp @@ -13,20 +13,31 @@ # include apache # class apache { - $apache = $::operatingsystem ? { /(Debian|Ubuntu)/ => 'apache2', /(RedHat|CentOS|Fedora)/ => 'httpd' } + $user = $::operatingsystem ? { + /(Debian|Ubuntu)/ => 'www-data', + /(RedHat|CentOS|Fedora)/ => 'apache' + } + package { $apache: - ensure => installed, - alias => 'apache' + ensure => latest, + alias => 'apache', } service { $apache: ensure => running, + enable => true, alias => 'apache', - require => Package['apache'] + require => Package['apache'], } + + @user { $user: + alias => 'apache', + } + + User <| alias == apache |> } diff --git a/.puppet/modules/cmmi_dir/manifests/init.pp b/.puppet/modules/cmmi_dir/manifests/init.pp new file mode 100644 index 000000000..33d2f7eec --- /dev/null +++ b/.puppet/modules/cmmi_dir/manifests/init.pp @@ -0,0 +1,15 @@ +define cmmi_dir ( + $configure='./configure', + $make='make && make install' +) { + Exec { + path => '/usr/bin:/bin', + cwd => "/usr/local/src/${name}", + } + + exec { "configure-${name}": + command => $configure, + } -> exec { "make-${name}": + command => $make, + } +} diff --git a/.vagrant-puppet/modules/epel/manifests/init.pp b/.puppet/modules/epel/manifests/init.pp similarity index 94% rename from .vagrant-puppet/modules/epel/manifests/init.pp rename to .puppet/modules/epel/manifests/init.pp index 65e0a2603..9ec1ba692 100644 --- a/.vagrant-puppet/modules/epel/manifests/init.pp +++ b/.puppet/modules/epel/manifests/init.pp @@ -16,7 +16,7 @@ class epel { yumrepo { 'epel': mirrorlist => "http://mirrors.fedoraproject.org/mirrorlist?repo=epel-6&arch=${::architecture}", - enabled => '0', + enabled => '1', gpgcheck => '0', descr => "Extra Packages for Enterprise Linux 6 - ${::architecture}" } diff --git a/.puppet/modules/git/manifests/init.pp b/.puppet/modules/git/manifests/init.pp new file mode 100644 index 000000000..9143e9f69 --- /dev/null +++ b/.puppet/modules/git/manifests/init.pp @@ -0,0 +1,13 @@ +# Class: git +# +# This class installs git. +# +# Sample Usage: +# +# include git +# +class git { + package { 'git': + ensure => latest, + } +} diff --git a/.puppet/modules/git_cmmi/manifests/init.pp b/.puppet/modules/git_cmmi/manifests/init.pp new file mode 100644 index 000000000..2c5302486 --- /dev/null +++ b/.puppet/modules/git_cmmi/manifests/init.pp @@ -0,0 +1,20 @@ +define git_cmmi ( + $url, + $configure='./configure', + $make='make && make install' +) { + include git + + $srcDir = '/usr/local/src' + + exec { "git-clone-${name}": + cwd => $srcDir, + path => '/usr/bin:/bin', + unless => "test -d '${srcDir}/${name}/.git'", + command => "git clone '${url}' '${name}'", + require => Class['git'], + } -> cmmi_dir { $name: + configure => $configure, + make => $make, + } +} diff --git a/.vagrant-puppet/modules/icinga/templates/ido2db-mysql.cfg.erb b/.puppet/modules/icinga/templates/ido2db-mysql.cfg.erb similarity index 100% rename from .vagrant-puppet/modules/icinga/templates/ido2db-mysql.cfg.erb rename to .puppet/modules/icinga/templates/ido2db-mysql.cfg.erb diff --git a/.vagrant-puppet/modules/icinga/templates/ido2db-pgsql.cfg.erb b/.puppet/modules/icinga/templates/ido2db-pgsql.cfg.erb similarity index 100% rename from .vagrant-puppet/modules/icinga/templates/ido2db-pgsql.cfg.erb rename to .puppet/modules/icinga/templates/ido2db-pgsql.cfg.erb diff --git a/.puppet/modules/icinga2/manifests/config.pp b/.puppet/modules/icinga2/manifests/config.pp new file mode 100644 index 000000000..cbdba06c0 --- /dev/null +++ b/.puppet/modules/icinga2/manifests/config.pp @@ -0,0 +1,42 @@ +# Define: icinga2::config +# +# Provide Icinga 2 configuration file +# +# Parameters: +# +# [*source*] - where to take the file from +# +# Requires: +# +# icinga2 +# +# Sample Usage: +# +# icinga2::config { 'constants'; +# source => 'puppet:///modules/icinga2_dev', +# } +# +# Provide configuration file '/etc/icinga2/constants.conf' +# from 'puppet:///modules/icinga2_dev/constants.conf' +# ('/path/to/puppet/modules/icinga2_dev/files/constants.conf') +# +define icinga2::config ($source) { + include icinga2 + + $path = "/etc/icinga2/${name}.conf" + + parent_dirs { $path: + user => 'icinga', + require => [ + User['icinga'], + File['icinga2cfgDir'] + ], + } + -> file { $path: + source => "${source}/${name}.conf", + owner => 'icinga', + group => 'icinga', + notify => Service['icinga2'], + require => User['icinga'], + } +} diff --git a/.puppet/modules/icinga2/manifests/feature.pp b/.puppet/modules/icinga2/manifests/feature.pp new file mode 100644 index 000000000..cfba05a9f --- /dev/null +++ b/.puppet/modules/icinga2/manifests/feature.pp @@ -0,0 +1,38 @@ +# Define: icinga2::feature +# +# Enable Icinga 2 feature +# +# Requires: +# +# icinga2 +# +# Sample Usage: +# +# icinga2::feature { 'example-feature'; } +# +define icinga2::feature ($source = undef) { + include icinga2 + + $target = "features-available/${name}" + $cfgpath = '/etc/icinga2' + $path = "${cfgpath}/features-enabled/${name}.conf" + + if $source != undef { + icinga2::config { $target: + source => $source, + } + } + + parent_dirs { $path: + user => 'icinga', + require => [ + User['icinga'], + File['icinga2cfgDir'] + ], + } + -> file { $path: + ensure => link, + target => "${cfgpath}/${target}.conf", + notify => Service['icinga2'], + } +} diff --git a/.puppet/modules/icinga2/manifests/init.pp b/.puppet/modules/icinga2/manifests/init.pp new file mode 100644 index 000000000..0545ba7c5 --- /dev/null +++ b/.puppet/modules/icinga2/manifests/init.pp @@ -0,0 +1,42 @@ +# Class: icinga2 +# +# This class installs Icinga 2. +# +# Requires: +# +# icinga_packages +# icinga2::feature +# +# Sample Usage: +# +# include icinga2 +# +class icinga2 { + include icinga_packages + + package { [ + 'icinga2', 'icinga2-doc', 'icinga2-debuginfo' + ]: + ensure => latest, + require => Class['icinga_packages'], + } + -> service { 'icinga2': + ensure => running, + enable => true, + require => User['icinga'], + } + + user { 'icinga': + ensure => present, + } + -> file { 'icinga2cfgDir': + path => '/etc/icinga2', + ensure => directory, + links => follow, + owner => 'icinga', + group => 'icinga', + mode => 6750, + } + + icinga2::feature { [ 'statusdata', 'command', 'compatlog' ]: } +} diff --git a/.vagrant-puppet/files/etc/icinga2/features-available/ido-mysql.conf b/.puppet/modules/icinga2_mysql/files/features-available/ido-mysql.conf similarity index 100% rename from .vagrant-puppet/files/etc/icinga2/features-available/ido-mysql.conf rename to .puppet/modules/icinga2_mysql/files/features-available/ido-mysql.conf diff --git a/.puppet/modules/icinga2_mysql/manifests/init.pp b/.puppet/modules/icinga2_mysql/manifests/init.pp new file mode 100644 index 000000000..acef7a5c1 --- /dev/null +++ b/.puppet/modules/icinga2_mysql/manifests/init.pp @@ -0,0 +1,34 @@ +# Class: icinga2_mysql +# +# This class installs Icinga 2 and Icinga-2-IDO-MySQL and set up the database for the last one. +# +# Requires: +# +# icinga_packages +# icinga2 +# icinga2::feature +# icinga2::config +# mysql::database::populate +# +# Sample Usage: +# +# include icinga2_mysql +# +class icinga2_mysql { + include icinga2 + include icinga_packages + + package { 'icinga2-ido-mysql': + ensure => latest, + require => Class['icinga_packages'], + } + -> mysql::database::populate { 'icinga2': + username => 'icinga2', + password => 'icinga2', + privileges => 'SELECT,INSERT,UPDATE,DELETE', + schemafile => '/usr/share/icinga2-ido-mysql/schema/mysql.sql', + } + -> icinga2::feature { 'ido-mysql': + source => 'puppet:///modules/icinga2_mysql', + } +} diff --git a/.vagrant-puppet/files/etc/icinga2/features-available/ido-pgsql.conf b/.puppet/modules/icinga2_pgsql/files/features-available/ido-pgsql.conf similarity index 100% rename from .vagrant-puppet/files/etc/icinga2/features-available/ido-pgsql.conf rename to .puppet/modules/icinga2_pgsql/files/features-available/ido-pgsql.conf diff --git a/.puppet/modules/icinga2_pgsql/manifests/init.pp b/.puppet/modules/icinga2_pgsql/manifests/init.pp new file mode 100644 index 000000000..2326449af --- /dev/null +++ b/.puppet/modules/icinga2_pgsql/manifests/init.pp @@ -0,0 +1,17 @@ +class icinga2_pgsql { + include icinga2 + include icinga_packages + + package { 'icinga2-ido-pgsql': + ensure => latest, + require => Class['icinga_packages'], + } + -> pgsql::database::populate { 'icinga2': + username => 'icinga2', + password => 'icinga2', + schemafile => '/usr/share/icinga2-ido-pgsql/schema/pgsql.sql', + } + -> icinga2::feature { 'ido-pgsql': + source => 'puppet:///modules/icinga2_pgsql', + } +} diff --git a/.puppet/modules/icinga_packages/manifests/init.pp b/.puppet/modules/icinga_packages/manifests/init.pp new file mode 100644 index 000000000..7e3e8d188 --- /dev/null +++ b/.puppet/modules/icinga_packages/manifests/init.pp @@ -0,0 +1,17 @@ +# Class: icinga_packages +# +# This class adds the YUM repository for the Icinga packages. +# +# Sample Usage: +# +# include icinga_packages +# +class icinga_packages { + yumrepo { 'icinga_packages': + baseurl => 'http://packages.icinga.org/epel/6/snapshot/', + enabled => '1', + gpgcheck => '1', + gpgkey => 'http://packages.icinga.org/icinga.key', + descr => "Icinga Repository - ${::architecture}" + } +} diff --git a/.puppet/modules/icingacli/manifests/init.pp b/.puppet/modules/icingacli/manifests/init.pp new file mode 100644 index 000000000..701cb6e14 --- /dev/null +++ b/.puppet/modules/icingacli/manifests/init.pp @@ -0,0 +1,12 @@ +# TODO(el): This module is not reuseable because it relies on vagrant paths +class icingacli { + file { '/usr/local/bin/icingacli': + ensure => link, + target => '/vagrant/bin/icingacli', + } + + file { '/etc/bash_completion.d/icingacli': + ensure => link, + target => '/vagrant/etc/bash_completion.d/icingacli', + } +} diff --git a/.puppet/modules/icingaweb2/manifests/config.pp b/.puppet/modules/icingaweb2/manifests/config.pp new file mode 100644 index 000000000..473d89d06 --- /dev/null +++ b/.puppet/modules/icingaweb2/manifests/config.pp @@ -0,0 +1,14 @@ +class icingaweb2::config ( + $config = hiera('icingaweb2::config') +) { + group { 'icingaweb': + ensure => present, + } + + file { [ "${config}", "${config}/enabledModules", "${config}/modules", "${config}/preferences" ]: + ensure => directory, + owner => 'root', + group => 'icingaweb', + mode => '2770', + } +} diff --git a/.puppet/modules/icingaweb2/manifests/config/general.pp b/.puppet/modules/icingaweb2/manifests/config/general.pp new file mode 100644 index 000000000..c2daec83f --- /dev/null +++ b/.puppet/modules/icingaweb2/manifests/config/general.pp @@ -0,0 +1,15 @@ +define icingaweb2::config::general ( + $source, + $config = hiera('icingaweb2::config'), + $replace = true +) { + include icingaweb2::config + + file { "${config}/${name}.ini": + content => template("${source}/${name}.ini.erb"), + owner => 'root', + group => 'icingaweb', + mode => 0660, + replace => $replace, + } +} diff --git a/.puppet/modules/icingaweb2/manifests/config/module.pp b/.puppet/modules/icingaweb2/manifests/config/module.pp new file mode 100644 index 000000000..69e5abd6b --- /dev/null +++ b/.puppet/modules/icingaweb2/manifests/config/module.pp @@ -0,0 +1,25 @@ +define icingaweb2::config::module ( + $module, + $source, + $config = hiera('icingaweb2::config'), + $replace = true +) { + include icingaweb2::config + + if ! defined(File["${config}/modules/${module}"]) { + file { "${config}/modules/${module}": + ensure => directory, + owner => 'root', + group => 'icingaweb', + mode => '2770', + } + } + + file { "${config}/modules/${module}/${name}.ini": + source => "${source}/modules/${module}/${name}.ini", + owner => 'root', + group => 'icingaweb', + mode => 0660, + replace => $replace, + } +} diff --git a/.vagrant-puppet/modules/monitoring-plugins/manifests/init.pp b/.puppet/modules/monitoring_plugins/manifests/init.pp similarity index 67% rename from .vagrant-puppet/modules/monitoring-plugins/manifests/init.pp rename to .puppet/modules/monitoring_plugins/manifests/init.pp index 6dc7be09d..64d080d11 100644 --- a/.vagrant-puppet/modules/monitoring-plugins/manifests/init.pp +++ b/.puppet/modules/monitoring_plugins/manifests/init.pp @@ -1,9 +1,9 @@ -class monitoring-plugins { +class monitoring_plugins { include epel # nagios plugins from epel package { 'nagios-plugins-all': - ensure => installed, + ensure => latest, require => Class['epel'] } -} \ No newline at end of file +} diff --git a/.puppet/modules/monitoring_test_config/manifests/init.pp b/.puppet/modules/monitoring_test_config/manifests/init.pp new file mode 100644 index 000000000..65ac53ec7 --- /dev/null +++ b/.puppet/modules/monitoring_test_config/manifests/init.pp @@ -0,0 +1,25 @@ +class monitoring_test_config { + package { [ + 'perl', + 'perl-Module-Install', + 'perl-CPAN', + 'perl-File-Which', + 'perl-Time-HiRes' + ]: + ensure => latest, + } + -> git_cmmi { 'Monitoring-Generator-TestConfig': + url => 'https://github.com/sni/Monitoring-Generator-TestConfig.git', + configure => 'perl Makefile.PL', + make => 'make && make test && make install', + } + -> exec { 'create_monitoring_test_config': + path => '/usr/local/bin:/usr/bin:/bin', + command => 'install -o root -g root -d /usr/local/share/misc/ && \ +create_monitoring_test_config.pl -l icinga /usr/local/share/misc/monitoring_test_config', + creates => '/usr/local/share/misc/monitoring_test_config', + } + -> monitoring_test_config::populate_plugins { [ + 'test_hostcheck.pl', 'test_servicecheck.pl' + ]: } +} diff --git a/.puppet/modules/monitoring_test_config/manifests/populate_plugins.pp b/.puppet/modules/monitoring_test_config/manifests/populate_plugins.pp new file mode 100644 index 000000000..347e4b127 --- /dev/null +++ b/.puppet/modules/monitoring_test_config/manifests/populate_plugins.pp @@ -0,0 +1,17 @@ +define monitoring_test_config::populate_plugins { + include icinga2 + include monitoring_plugins + include monitoring_test_config + + file { "/usr/lib64/nagios/plugins/${name}": + owner => 'icinga', + group => 'icinga', + source => "/usr/local/share/misc/monitoring_test_config/plugins/${name}", + require => [ + User['icinga'], + Exec['create_monitoring_test_config'], + Class['monitoring_plugins'] + ], + notify => Service['icinga2'], + } +} diff --git a/.puppet/modules/motd/files/motd b/.puppet/modules/motd/files/motd new file mode 100644 index 000000000..3e32ee517 --- /dev/null +++ b/.puppet/modules/motd/files/motd @@ -0,0 +1,19 @@ +88 88 +88 "" +88 +88 ,adPPYba, 88 8b,dPPYba, ,adPPYb,d8 ,adPPYYba, +88 a8" "" 88 88P' `"8a a8" `Y88 "" `Y8 +88 8b 88 88 88 8b 88 ,adPPPPP88 +88 "8a, ,aa 88 88 88 "8a, ,d88 88, ,88 +88 `"Ybbd8"' 88 88 88 `"YbbdP"Y8 `"8bbdP"Y8 + aa, ,88 + "Y8bbdP" + +I8, 8 ,8I 88 ad888888b, +`8b d8b d8' 88 d8" "88 + "8, ,8"8, ,8" 88 a8P + Y8 8P Y8 8P ,adPPYba, 88,dPPYba, ,d8P" + `8b d8' `8b d8' a8P_____88 88P' "8a a8P" + `8a a8' `8a a8' 8PP""""""" 88 d8 a8P' + `8a8' `8a8' "8b, ,aa 88b, ,a8" d8" + `8' `8' `"Ybbd8"' 8Y"Ybbd8"' 88888888888 diff --git a/.puppet/modules/motd/manifests/init.pp b/.puppet/modules/motd/manifests/init.pp new file mode 100644 index 000000000..acb744daf --- /dev/null +++ b/.puppet/modules/motd/manifests/init.pp @@ -0,0 +1,7 @@ +class motd { + file { '/etc/motd': + source => 'puppet:///modules/motd/motd', + owner => root, + group => root, + } +} diff --git a/.puppet/modules/mysql/manifests/database/create.pp b/.puppet/modules/mysql/manifests/database/create.pp new file mode 100644 index 000000000..fff93c6e6 --- /dev/null +++ b/.puppet/modules/mysql/manifests/database/create.pp @@ -0,0 +1,33 @@ +# Define: mysql::database::create +# +# Create a MySQL database +# +# Parameters: +# +# [*username*] - name of the user the database belongs to +# [*password*] - password of the user the database belongs to +# [*privileges*] - privileges of the user the database belongs to +# +# Requires: +# +# mysql +# +# Sample Usage: +# +# mysql::database::create { 'icinga2': +# username => 'icinga2', +# password => 'icinga2', +# privileges => 'SELECT,INSERT,UPDATE,DELETE', +# } +# +define mysql::database::create ($username, $password, $privileges) { + include mysql + + exec { "create-mysql-${name}-db": + unless => "mysql -u${username} -p${password} ${name}", + command => "mysql -uroot -e \"CREATE DATABASE ${name}; \ +GRANT ${privileges} ON ${name}.* TO ${username}@localhost \ +IDENTIFIED BY '${password}';\"", + require => Class['mysql'] + } +} diff --git a/.puppet/modules/mysql/manifests/database/populate.pp b/.puppet/modules/mysql/manifests/database/populate.pp new file mode 100644 index 000000000..dc54a0800 --- /dev/null +++ b/.puppet/modules/mysql/manifests/database/populate.pp @@ -0,0 +1,39 @@ +# Define: mysql::database::populate +# +# Create and populate a MySQL database +# +# Parameters: +# +# [*username*] - name of the user the database belongs to +# [*password*] - password of the user the database belongs to +# [*privileges*] - privileges of the user the database belongs to +# [*schemafile*] - file with the schema for the database +# +# Requires: +# +# mysql::database::create +# +# Sample Usage: +# +# mysql::database::populate { 'icinga2': +# username => 'icinga2', +# password => 'icinga2', +# privileges => 'SELECT,INSERT,UPDATE,DELETE', +# schemafile => '/usr/share/icinga2-ido-mysql/schema/mysql.sql', +# } +# +define mysql::database::populate ($username, $password, $privileges, $schemafile) { + Exec { path => '/bin:/usr/bin' } + + mysql::database::create { $name: + username => $username, + password => $password, + privileges => $privileges, + } + + exec { "populate-${name}-mysql-db": + onlyif => "mysql -u${username} -p${password} ${name} -e \"SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '${name}';\" 2>/dev/null |grep -qEe '^ *0 *$'", + command => "mysql -uroot ${name} < ${schemafile}", + require => Mysql::Database::Create[$name], + } +} diff --git a/.vagrant-puppet/modules/mysql/manifests/init.pp b/.puppet/modules/mysql/manifests/init.pp similarity index 82% rename from .vagrant-puppet/modules/mysql/manifests/init.pp rename to .puppet/modules/mysql/manifests/init.pp index f0cab3fdb..a235a540c 100644 --- a/.vagrant-puppet/modules/mysql/manifests/init.pp +++ b/.puppet/modules/mysql/manifests/init.pp @@ -16,15 +16,15 @@ class mysql { Exec { path => '/usr/bin' } - package { - 'mysql': - ensure => installed; - 'mysql-server': - ensure => installed; + package { [ + 'mysql', 'mysql-server' + ]: + ensure => latest, } service { 'mysqld': ensure => running, + enable => true, require => Package['mysql-server'] } diff --git a/.vagrant-puppet/modules/mysql/templates/my.cnf.erb b/.puppet/modules/mysql/templates/my.cnf.erb similarity index 100% rename from .vagrant-puppet/modules/mysql/templates/my.cnf.erb rename to .puppet/modules/mysql/templates/my.cnf.erb diff --git a/.vagrant-puppet/modules/openldap/manifests/init.pp b/.puppet/modules/openldap/manifests/init.pp similarity index 78% rename from .vagrant-puppet/modules/openldap/manifests/init.pp rename to .puppet/modules/openldap/manifests/init.pp index e9f3c504b..069c4a157 100644 --- a/.vagrant-puppet/modules/openldap/manifests/init.pp +++ b/.puppet/modules/openldap/manifests/init.pp @@ -14,8 +14,8 @@ # class openldap { - package { ['openldap-servers', 'openldap-clients']: - ensure => installed + package { ['openldap-servers', 'openldap-clients']: + ensure => latest, } service { 'slapd': diff --git a/.puppet/modules/parent_dirs/manifests/init.pp b/.puppet/modules/parent_dirs/manifests/init.pp new file mode 100644 index 000000000..e5e4e38d7 --- /dev/null +++ b/.puppet/modules/parent_dirs/manifests/init.pp @@ -0,0 +1,8 @@ +# TODO(el): Remove this. It's always executed and hackish +define parent_dirs ($user = 'root') { + exec { "parent_dirs-${name}": + command => "mkdir -p \"\$(dirname \"\$(readlink -m '${name}')\")\"", + path => '/bin:/usr/bin', + user => $user, + } +} diff --git a/.puppet/modules/pgsql/manifests/database/create.pp b/.puppet/modules/pgsql/manifests/database/create.pp new file mode 100644 index 000000000..97fcb163d --- /dev/null +++ b/.puppet/modules/pgsql/manifests/database/create.pp @@ -0,0 +1,32 @@ +# Define: pgsql::database::create +# +# Create a PgSQL database +# +# Parameters: +# +# [*username*] - name of the user the database belongs to +# [*password*] - password of the user the database belongs to +# +# Requires: +# +# pgsql +# +# Sample Usage: +# +# pgsql::database::create { 'icinga2': +# username => 'icinga2', +# password => 'icinga2', +# } +# +define pgsql::database::create ($username, $password) { + include pgsql + + exec { "create-pgsql-${name}-db": + unless => "psql -tAc \"SELECT 1 FROM pg_roles WHERE rolname='${username}'\" | grep -q 1", + command => "psql -c \"CREATE ROLE ${username} WITH LOGIN PASSWORD '${password}';\" && \ +createdb -O ${username} -E UTF8 -T template0 ${name} && \ +createlang plpgsql ${name}", + user => 'postgres', + require => Class['pgsql'] + } +} diff --git a/.puppet/modules/pgsql/manifests/database/populate.pp b/.puppet/modules/pgsql/manifests/database/populate.pp new file mode 100644 index 000000000..8663ff3f1 --- /dev/null +++ b/.puppet/modules/pgsql/manifests/database/populate.pp @@ -0,0 +1,37 @@ +# Define: pgsql::database::populate +# +# Create and populate a PgSQL database +# +# Parameters: +# +# [*username*] - name of the user the database belongs to +# [*password*] - password of the user the database belongs to +# [*schemafile*] - file with the schema for the database +# +# Requires: +# +# pgsql::database::create +# +# Sample Usage: +# +# pgsql::database::populate { 'icinga2': +# username => 'icinga2', +# password => 'icinga2', +# schemafile => '/usr/share/icinga2-ido-pgsql/schema/pgsql.sql', +# } +# +define pgsql::database::populate ($username, $password, $schemafile) { + Exec { path => '/bin:/usr/bin' } + + pgsql::database::create { $name: + username => $username, + password => $password, + } + + exec { "populate-${name}-pgsql-db": + onlyif => "psql -U ${username} -d ${name} -c \"SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '${name}';\" 2>/dev/null |grep -qEe '^ *0 *$'", + command => "psql -U ${username} -d ${name} < ${schemafile}", + user => 'postgres', + require => Pgsql::Database::Create[$name], + } +} diff --git a/.vagrant-puppet/modules/pgsql/manifests/init.pp b/.puppet/modules/pgsql/manifests/init.pp similarity index 87% rename from .vagrant-puppet/modules/pgsql/manifests/init.pp rename to .puppet/modules/pgsql/manifests/init.pp index 36e12bb11..4b48cf895 100644 --- a/.vagrant-puppet/modules/pgsql/manifests/init.pp +++ b/.puppet/modules/pgsql/manifests/init.pp @@ -17,11 +17,10 @@ class pgsql { Exec { path => '/sbin:/bin:/usr/bin' } - package { - 'postgresql': - ensure => installed; - 'postgresql-server': - ensure => installed; + package { [ + 'postgresql', 'postgresql-server' + ]: + ensure => latest, } exec { 'initdb': diff --git a/.vagrant-puppet/modules/pgsql/templates/pg_hba.conf.erb b/.puppet/modules/pgsql/templates/pg_hba.conf.erb similarity index 100% rename from .vagrant-puppet/modules/pgsql/templates/pg_hba.conf.erb rename to .puppet/modules/pgsql/templates/pg_hba.conf.erb diff --git a/.vagrant-puppet/modules/php/manifests/extension.pp b/.puppet/modules/php/manifests/extension.pp similarity index 100% rename from .vagrant-puppet/modules/php/manifests/extension.pp rename to .puppet/modules/php/manifests/extension.pp diff --git a/.vagrant-puppet/modules/php/manifests/init.pp b/.puppet/modules/php/manifests/init.pp similarity index 72% rename from .vagrant-puppet/modules/php/manifests/init.pp rename to .puppet/modules/php/manifests/init.pp index 1a8e31746..dd6df83b3 100644 --- a/.vagrant-puppet/modules/php/manifests/init.pp +++ b/.puppet/modules/php/manifests/init.pp @@ -19,10 +19,15 @@ class php { include apache package { 'php': - ensure => installed, + ensure => latest, require => Package['apache'], notify => Service['apache'] } + # TODO(el): Always executed. Should be a resource + -> exec { 'php-timezone': + command => 'sed -re $\'s#^;?(date\\.timezone =).*$#\\1 "UTC"#\' -i /etc/php.ini', + notify => Service['apache'], + } file { '/etc/php.d/error_reporting.ini': content => template('php/error_reporting.ini.erb'), diff --git a/.vagrant-puppet/modules/php/templates/error_reporting.ini.erb b/.puppet/modules/php/templates/error_reporting.ini.erb similarity index 100% rename from .vagrant-puppet/modules/php/templates/error_reporting.ini.erb rename to .puppet/modules/php/templates/error_reporting.ini.erb diff --git a/.vagrant-puppet/modules/php/templates/xdebug_settings.ini.erb b/.puppet/modules/php/templates/xdebug_settings.ini.erb similarity index 100% rename from .vagrant-puppet/modules/php/templates/xdebug_settings.ini.erb rename to .puppet/modules/php/templates/xdebug_settings.ini.erb diff --git a/.puppet/modules/zend_framework/manifests/init.pp b/.puppet/modules/zend_framework/manifests/init.pp new file mode 100644 index 000000000..1e54259b1 --- /dev/null +++ b/.puppet/modules/zend_framework/manifests/init.pp @@ -0,0 +1,24 @@ +# Class: zend_framework +# +# This class installs the Zend Framework. +# +# Requires: +# +# epel +# +# Sample Usage: +# +# include zend_framework +# +class zend_framework { + include epel + + package { [ + 'php-ZendFramework', + 'php-ZendFramework-Db-Adapter-Pdo-Mysql', + 'php-ZendFramework-Db-Adapter-Pdo-Pgsql' + ]: + ensure => latest, + require => Class['epel'], + } +} diff --git a/.vagrant-puppet/files/etc/icinga2/conf.d/commands.conf b/.puppet/profiles/icinga2_dev/files/conf.d/commands.conf similarity index 100% rename from .vagrant-puppet/files/etc/icinga2/conf.d/commands.conf rename to .puppet/profiles/icinga2_dev/files/conf.d/commands.conf diff --git a/.vagrant-puppet/files/etc/icinga2/conf.d/test-config.conf b/.puppet/profiles/icinga2_dev/files/conf.d/test-config.conf similarity index 89% rename from .vagrant-puppet/files/etc/icinga2/conf.d/test-config.conf rename to .puppet/profiles/icinga2_dev/files/conf.d/test-config.conf index 2dde681bf..4e3260b85 100644 --- a/.vagrant-puppet/files/etc/icinga2/conf.d/test-config.conf +++ b/.puppet/profiles/icinga2_dev/files/conf.d/test-config.conf @@ -45,19 +45,19 @@ object HostGroup "all-hosts" { assign where true } -local host_types = ["ok", "random", "down", "up", "unreachable", "pending"] +var host_types = ["ok", "random", "down", "up", "unreachable", "pending"] -__for (host_type in host_types) { +for (host_type in host_types) { object HostGroup "all-" + host_type use (host_type) { display_name = "All " + host_type + " hosts" assign where host.vars.check_type == host_type } } -local service_types = ["ok", "warning", "critical", "unknown", "flapping", "pending"] +var service_types = ["ok", "warning", "critical", "unknown", "flapping", "pending"] // Servicegroups -__for (service_type in service_types) { +for (service_type in service_types) { object ServiceGroup "service-" + service_type use (service_type) { display_name = "All " + service_type + " services" assign where service.vars.check_type == service_type @@ -68,7 +68,7 @@ __for (service_type in service_types) { // Services // --------------------------------------------------------------------------------------------------------------------- -__function createService(service_type, num) { +function createService(service_type, num) { apply Service "service-" + service_type + "-" + string(num + 1) use (service_type) { import "generic-service" @@ -80,8 +80,8 @@ __function createService(service_type, num) { } } -__for (num in range(4)) { - __for (service_type in service_types) { +for (num in range(4)) { + for (service_type in service_types) { createService(service_type, num) } } @@ -90,7 +90,7 @@ __for (num in range(4)) { // Hosts // --------------------------------------------------------------------------------------------------------------------- -__function createHost(checkType, checkConfig, num, checkEnabled) { +function createHost(checkType, checkConfig, num, checkEnabled) { object Host "test-" + checkType + "-" + string(num + 1) use (checkEnabled, checkType, checkConfig) { import "generic-host" address = "127.0.0.1" @@ -101,7 +101,7 @@ __function createHost(checkType, checkConfig, num, checkEnabled) { } } -__for (num in range(10)) { +for (num in range(10)) { createHost("ok", [ "ok" ], num, true) createHost("random", [ "random", "flapping" ], num, true) createHost("down", [ "warning", "critical" ], num, true) diff --git a/.vagrant-puppet/files/etc/icinga2/constants.conf b/.puppet/profiles/icinga2_dev/files/constants.conf similarity index 100% rename from .vagrant-puppet/files/etc/icinga2/constants.conf rename to .puppet/profiles/icinga2_dev/files/constants.conf diff --git a/.puppet/profiles/icinga2_dev/manifests/init.pp b/.puppet/profiles/icinga2_dev/manifests/init.pp new file mode 100644 index 000000000..484042b64 --- /dev/null +++ b/.puppet/profiles/icinga2_dev/manifests/init.pp @@ -0,0 +1,24 @@ +# Class: icinga2_dev +# +# This class installs Icinga 2 w/ MySQL and provides Icinga 2 test configuration. +# +# Requires: +# +# icinga2_mysql +# icinga2::config +# +# Sample Usage: +# +# include icinga2_dev +# +class icinga2_dev { + include icinga2_mysql + include icinga2_pgsql + include monitoring_plugins + include monitoring_test_config + + icinga2::config { [ + 'conf.d/test-config', 'conf.d/commands', 'constants' ]: + source => 'puppet:///modules/icinga2_dev', + } +} diff --git a/.puppet/profiles/icingaweb2_dev/files/modules/monitoring/backends.ini b/.puppet/profiles/icingaweb2_dev/files/modules/monitoring/backends.ini new file mode 100644 index 000000000..55f8e3115 --- /dev/null +++ b/.puppet/profiles/icingaweb2_dev/files/modules/monitoring/backends.ini @@ -0,0 +1,12 @@ +[ido-mysql] +type = ido +resource = ido-mysql + +[ido-pgsql] +type = ido +resource = ido-pgsql + +[livestatus] +disabled = 1 +type = livestatus +resource = livestatus diff --git a/.puppet/profiles/icingaweb2_dev/files/modules/monitoring/config.ini b/.puppet/profiles/icingaweb2_dev/files/modules/monitoring/config.ini new file mode 100644 index 000000000..9b69fe86f --- /dev/null +++ b/.puppet/profiles/icingaweb2_dev/files/modules/monitoring/config.ini @@ -0,0 +1,2 @@ +[security] +protected_customvars = "*pw*,*pass*,community" diff --git a/.puppet/profiles/icingaweb2_dev/files/modules/monitoring/instances.ini b/.puppet/profiles/icingaweb2_dev/files/modules/monitoring/instances.ini new file mode 100644 index 000000000..a47b06629 --- /dev/null +++ b/.puppet/profiles/icingaweb2_dev/files/modules/monitoring/instances.ini @@ -0,0 +1,2 @@ +[icinga] +path = "/var/run/icinga2/cmd/icinga2.cmd" diff --git a/.vagrant-puppet/modules/openldap/files/db.ldif b/.puppet/profiles/icingaweb2_dev/files/openldap/db.ldif similarity index 100% rename from .vagrant-puppet/modules/openldap/files/db.ldif rename to .puppet/profiles/icingaweb2_dev/files/openldap/db.ldif diff --git a/.vagrant-puppet/modules/openldap/files/dit.ldif b/.puppet/profiles/icingaweb2_dev/files/openldap/dit.ldif similarity index 100% rename from .vagrant-puppet/modules/openldap/files/dit.ldif rename to .puppet/profiles/icingaweb2_dev/files/openldap/dit.ldif diff --git a/.vagrant-puppet/modules/openldap/files/users.ldif b/.puppet/profiles/icingaweb2_dev/files/openldap/users.ldif similarity index 100% rename from .vagrant-puppet/modules/openldap/files/users.ldif rename to .puppet/profiles/icingaweb2_dev/files/openldap/users.ldif diff --git a/.puppet/profiles/icingaweb2_dev/manifests/init.pp b/.puppet/profiles/icingaweb2_dev/manifests/init.pp new file mode 100644 index 000000000..379f75247 --- /dev/null +++ b/.puppet/profiles/icingaweb2_dev/manifests/init.pp @@ -0,0 +1,140 @@ +class icingaweb2_dev ( + $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'), +) { + include apache + include php + include icingaweb2::config + include icingacli + include icinga_packages + include openldap + + # TODO(el): Only include zend_framework. Apache does not have to be notified + class { 'zend_framework': + notify => Service['apache'], + } + + # TODO(el): icinga-gui is not a icingaweb2_dev package + package { [ 'php-pdo', 'php-ldap', 'php-phpunit-PHPUnit', 'icinga-gui' ]: + ensure => latest, + notify => Service['apache'], + require => Class['icinga_packages'], + } + + Exec { path => '/usr/local/bin:/usr/bin:/bin' } + + # TODO(el): Enabling/disabling modules should be a resource + User <| alias == apache |> { groups +> 'icingaweb' } + -> exec { 'enable-monitoring-module': + command => 'icingacli module enable monitoring', + user => 'apache', + require => Class[[ 'icingacli', 'apache' ]], + } + -> exec { 'enable-test-module': + command => 'icingacli module enable test', + user => 'apache' + } + + # TODO(el): 'icingacmd' is NOT a icingaweb2_dev group + group { 'icingacmd': + ensure => present, + } + + User <| alias == apache |> { groups +> 'icingacmd' } + + $log_dir = inline_template('<%= File.dirname(@log) %>') + file { $log_dir: + ensure => directory, + owner => 'root', + group => 'icingaweb', + mode => '2775' + } + + $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/\');\"" + + mysql::database::populate { "${db_name}": + username => "${db_user}", + password => "${db_pass}", + privileges => 'ALL', + schemafile => '/vagrant/etc/schema/mysql.schema.sql', + } + -> exec { 'mysql-icingaadmin': + 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}", + } + + pgsql::database::populate { "${db_name}": + username => "${db_user}", + password => "${db_pass}", + schemafile => '/vagrant/etc/schema/pgsql.schema.sql', + } + -> exec { 'pgsql-icingaadmin': + 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}", + } + + file { '/etc/httpd/conf.d/icingaweb.conf': + content => template("$name/icingaweb.conf.erb"), + notify => Service['apache'], + } + + icingaweb2::config::general { 'authentication': + source => $name, + } + + icingaweb2::config::general { [ 'config', 'resources' ]: + source => $name, + replace => false, + } + + icingaweb2::config::module { [ 'backends', 'config', 'instances' ]: + module => 'monitoring', + source => 'puppet:///modules/icingaweb2_dev', + } + + # TODO(el): Should be a resource + package { 'iptables': + ensure => latest + } + -> exec { 'iptables-allow-http': + unless => 'grep -qe "-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT" /etc/sysconfig/iptables', + command => '/sbin/iptables -I INPUT 1 -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT && /sbin/iptables-save > /etc/sysconfig/iptables' + } + + # TODO(el): Don't define inside a class + 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': + # TODO(el): Split the command and use unless instead of trying to populate openldap everytime + 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' + ]] + ], + } + + # TODO(el): Should be a module + package { 'php-deepend-Mockery': + ensure => latest, + } +} diff --git a/.puppet/profiles/icingaweb2_dev/templates/authentication.ini.erb b/.puppet/profiles/icingaweb2_dev/templates/authentication.ini.erb new file mode 100644 index 000000000..f28395e18 --- /dev/null +++ b/.puppet/profiles/icingaweb2_dev/templates/authentication.ini.erb @@ -0,0 +1,16 @@ +[autologin] +backend = autologin + +[icingaweb-mysql] +backend = db +resource = icingaweb-mysql + +[icingaweb-pgsql] +backend = db +resource = icingaweb-pgsql + +[local-ldap] +backend = ldap +resource = local-ldap +user_class = inetOrgPerson +user_name_attribute = uid diff --git a/.puppet/profiles/icingaweb2_dev/templates/config.ini.erb b/.puppet/profiles/icingaweb2_dev/templates/config.ini.erb new file mode 100644 index 000000000..13ef6710f --- /dev/null +++ b/.puppet/profiles/icingaweb2_dev/templates/config.ini.erb @@ -0,0 +1,7 @@ +[logging] +log = "file" +file = "<%= @log %>" +level = DEBUG + +[preferences] +type = "ini" diff --git a/.vagrant-puppet/files/etc/httpd/conf.d/icingaweb.conf b/.puppet/profiles/icingaweb2_dev/templates/icingaweb.conf.erb similarity index 77% rename from .vagrant-puppet/files/etc/httpd/conf.d/icingaweb.conf rename to .puppet/profiles/icingaweb2_dev/templates/icingaweb.conf.erb index 0b45bea1f..d19dbe9ee 100644 --- a/.vagrant-puppet/files/etc/httpd/conf.d/icingaweb.conf +++ b/.puppet/profiles/icingaweb2_dev/templates/icingaweb.conf.erb @@ -1,4 +1,4 @@ -Alias /icingaweb /vagrant/public +Alias /<%= @web_path %> /vagrant/public Options FollowSymLinks @@ -6,12 +6,12 @@ Alias /icingaweb /vagrant/public Order allow,deny Allow from all - # SetEnv ICINGAWEB_CONFIGDIR /etc/icingaweb + # SetEnv ICINGAWEB_CONFIGDIR <%= @config %> EnableSendfile Off RewriteEngine on - RewriteBase /icingaweb/ + RewriteBase /<%= @web_path %>/ RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d diff --git a/.puppet/profiles/icingaweb2_dev/templates/resources.ini.erb b/.puppet/profiles/icingaweb2_dev/templates/resources.ini.erb new file mode 100644 index 000000000..8066a47a5 --- /dev/null +++ b/.puppet/profiles/icingaweb2_dev/templates/resources.ini.erb @@ -0,0 +1,43 @@ +[icingaweb-mysql] +type = db +db = mysql +host = localhost +port = 3306 +username = <%= @db_user %> +password = <%= @db_pass %> +dbname = <%= @db_name %> + +[icingaweb-pgsql] +type = db +db = pgsql +host = localhost +port = 5432 +username = <%= @db_user %> +password = <%= @db_pass %> +dbname = <%= @db_name %> + +[ido-mysql] +type = db +db = mysql +host = localhost +port = 3306 +password = icinga2 +username = icinga2 +dbname = icinga2 + +[ido-pgsql] +type = db +db = pgsql +host = localhost +port = 5432 +password = icinga2 +username = icinga2 +dbname = icinga2 + +[local-ldap] +type = ldap +hostname = localhost +port = 389 +root_dn = "ou=people,dc=icinga,dc=org" +bind_dn = "cn=admin,cn=config" +bind_pw = admin diff --git a/.vagrant-puppet/files/etc/icingaweb/authentication.ini b/.vagrant-puppet/files/etc/icingaweb/authentication.ini deleted file mode 100644 index 3da806df1..000000000 --- a/.vagrant-puppet/files/etc/icingaweb/authentication.ini +++ /dev/null @@ -1,15 +0,0 @@ -[autologin] -backend = autologin -; -; If you want to strip the domain -; strip_username_regexp = /\@[^$]+$/ - -[internal_ldap_authentication] -backend = ldap -resource = internal_ldap -user_class = inetOrgPerson -user_name_attribute = uid - -[internal_db_authentication] -backend = db -resource = internal_db diff --git a/.vagrant-puppet/files/etc/icingaweb/modules/monitoring/backends.ini b/.vagrant-puppet/files/etc/icingaweb/modules/monitoring/backends.ini deleted file mode 100644 index 6805f2e8b..000000000 --- a/.vagrant-puppet/files/etc/icingaweb/modules/monitoring/backends.ini +++ /dev/null @@ -1,19 +0,0 @@ -[localdb] - -type = ido -resource = "ido" - -[locallive] -disabled = "1" -type = livestatus -resource = livestatus - -[localfile] -disabled = "1" -type = statusdat -resource = statusdat - -;[localfailsafe] -;enabled=false -;type = combo -;backends = localdb, locallive, localfile diff --git a/.vagrant-puppet/files/etc/icingaweb/modules/monitoring/instances.ini b/.vagrant-puppet/files/etc/icingaweb/modules/monitoring/instances.ini deleted file mode 100644 index 037baa8b9..000000000 --- a/.vagrant-puppet/files/etc/icingaweb/modules/monitoring/instances.ini +++ /dev/null @@ -1,2 +0,0 @@ -[icinga] -path = "/var/run/icinga2/cmd/icinga2.cmd" diff --git a/.vagrant-puppet/files/etc/icingaweb/resources.ini b/.vagrant-puppet/files/etc/icingaweb/resources.ini deleted file mode 100644 index 3935906eb..000000000 --- a/.vagrant-puppet/files/etc/icingaweb/resources.ini +++ /dev/null @@ -1,34 +0,0 @@ -[internal_db] -type = db -db = mysql -host = localhost -port = 3306 -password = icingaweb -username = icingaweb -dbname = icingaweb - -[ido] -type = db -db = mysql -host = localhost -port = 3306 -password = icinga2 -username = icinga2 -dbname = icinga2 - -[statusdat] -type = statusdat -status_file = /usr/local/icinga-mysql/var/status.dat -object_file = /usr/local/icinga-mysql/var/objects.cache - -[livestatus] -type = livestatus -socket = /usr/local/icinga-mysql/var/rw/live - -[internal_ldap] -type = ldap -hostname = localhost -port = 389 -root_dn = "ou=people, dc=icinga, dc=org" -bind_dn = "cn=admin,cn=config" -bind_pw = admin diff --git a/.vagrant-puppet/files/etc/init.d/icinga_command_proxy b/.vagrant-puppet/files/etc/init.d/icinga_command_proxy deleted file mode 100644 index 77059981f..000000000 --- a/.vagrant-puppet/files/etc/init.d/icinga_command_proxy +++ /dev/null @@ -1,71 +0,0 @@ -#!/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/$PROG.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 - diff --git a/.vagrant-puppet/files/etc/motd b/.vagrant-puppet/files/etc/motd deleted file mode 100644 index 7e6677c20..000000000 --- a/.vagrant-puppet/files/etc/motd +++ /dev/null @@ -1,16 +0,0 @@ - ______ ___ -/\__ _\ __ /'___`\ -\/_/\ \/ ___ /\_\ ___ __ __ /\_\ /\ \ - \ \ \ /'___\/\ \ /' _ `\ /'_ `\ /'__`\ \/_/// /__ - \_\ \__/\ \__/\ \ \/\ \/\ \/\ \L\ \/\ \L\.\_ // /_\ \ - /\_____\ \____\\ \_\ \_\ \_\ \____ \ \__/.\_\ /\______/ - \/_____/\/____/ \/_/\/_/\/_/\/___L\ \/__/\/_/ \/_____/ - /\____/ - \_/__/ - __ __ __ -/\ \ __/\ \ /\ \ -\ \ \/\ \ \ \ __\ \ \____ - \ \ \ \ \ \ \ /'__`\ \ '__`\ - \ \ \_/ \_\ \/\ __/\ \ \L\ \ - \ `\___x___/\ \____\\ \_,__/ - '\/__//__/ \/____/ \/___/ diff --git a/.vagrant-puppet/files/usr/local/bin/icinga_command_proxy b/.vagrant-puppet/files/usr/local/bin/icinga_command_proxy deleted file mode 100644 index de7cb157c..000000000 --- a/.vagrant-puppet/files/usr/local/bin/icinga_command_proxy +++ /dev/null @@ -1,42 +0,0 @@ -#!/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 diff --git a/.vagrant-puppet/files/var/www/html/icingaweb/index.php b/.vagrant-puppet/files/var/www/html/icingaweb/index.php deleted file mode 100644 index 9e452ac70..000000000 --- a/.vagrant-puppet/files/var/www/html/icingaweb/index.php +++ /dev/null @@ -1,5 +0,0 @@ - '/bin:/usr/bin:/sbin:/usr/sbin' } - -$icingaVersion = '1.11.5' -$icinga2Version = '2.0.1' -$pluginVersion = '2.0' -$livestatusVersion = '1.2.4p5' -$phantomjsVersion = '1.9.1' -$casperjsVersion = '1.0.2' - -exec { 'create-mysql-icinga-db': - unless => 'mysql -uicinga -picinga icinga', - command => 'mysql -uroot -e "CREATE DATABASE icinga; \ - GRANT SELECT,INSERT,UPDATE,DELETE ON icinga.* TO icinga@localhost \ - IDENTIFIED BY \'icinga\';"', - require => Service['mysqld'] -} - -exec { 'create-mysql-icinga2-db': - unless => 'mysql -uicinga2 -picinga2 icinga2', - command => 'mysql -uroot -e "CREATE DATABASE icinga2; \ - GRANT SELECT,INSERT,UPDATE,DELETE ON icinga2.* to icinga2@localhost \ - IDENTIFIED BY \'icinga2\';"', - require => Service['mysqld'] -} - -exec{ 'create-pgsql-icinga-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 \'icingaweb\';" && \ - sudo -u postgres createdb -O icinga -E UTF8 -T template0 icinga && \ - sudo -u postgres createlang plpgsql icinga', - require => Service['postgresql'] -} - -$icinga_packages = [ 'gcc', 'glibc', 'glibc-common', 'gd', 'gd-devel', - 'libpng', 'libpng-devel', 'net-snmp', 'net-snmp-devel', 'net-snmp-utils', - 'libdbi', 'libdbi-devel', 'libdbi-drivers', - 'libdbi-dbd-mysql', 'libdbi-dbd-pgsql' ] -package { $icinga_packages: ensure => installed } - -php::extension { ['php-mysql', 'php-pgsql', 'php-ldap']: - require => [ Class['mysql'], Class['pgsql'], Class['openldap'] ] -} - -php::extension { 'php-gd': } - -group { 'icinga-cmd': - ensure => present -} - -group { 'icingacmd': - ensure => present, - require => Package['icinga2'] -} - -user { 'icinga': - ensure => present, - groups => 'icinga-cmd', - managehome => false -} - -user { 'apache': - groups => ['icinga-cmd', 'vagrant', 'icingacmd'], - require => [ Class['apache'], Group['icinga-cmd'], Group['icingacmd'] ] -} - -cmmi { 'icinga-mysql': - url => "https://github.com/Icinga/icinga-core/releases/download/v${icingaVersion}/icinga-${icingaVersion}.tar.gz", - output => "icinga-${icingaVersion}.tar.gz", - flags => '--prefix=/usr/local/icinga-mysql --with-command-group=icinga-cmd \ - --enable-idoutils --with-init-dir=/usr/local/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 \ - --with-plugin-dir=/usr/lib64/nagios/plugins', - creates => '/usr/local/icinga-mysql', - make => 'make all && make fullinstall install-config', - require => [ User['icinga'], Class['monitoring-plugins'], Package['apache'] ], - notify => Service['apache'] -} - -file { '/etc/init.d/icinga-mysql': - source => '/usr/local/icinga-mysql/etc/init.d/icinga', - require => Cmmi['icinga-mysql'] -} - -file { '/etc/init.d/ido2db-mysql': - source => '/usr/local/icinga-mysql/etc/init.d/ido2db', - require => Cmmi['icinga-mysql'] -} - -cmmi { 'icinga-pgsql': - url => "https://github.com/Icinga/icinga-core/releases/download/v${icingaVersion}/icinga-${icingaVersion}.tar.gz", - output => "icinga-${icingaVersion}.tar.gz", - flags => '--prefix=/usr/local/icinga-pgsql \ - --with-command-group=icinga-cmd --enable-idoutils \ - --with-init-dir=/usr/local/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 \ - --with-plugin-dir=/usr/lib64/nagios/plugins', - creates => '/usr/local/icinga-pgsql', - make => 'make all && make fullinstall install-config', - require => [ User['icinga'], Class['monitoring-plugins'], Package['apache'] ], - notify => Service['apache'] -} - -file { '/etc/init.d/icinga-pgsql': - source => '/usr/local/icinga-pgsql/etc/init.d/icinga', - require => Cmmi['icinga-pgsql'] -} - -file { '/etc/init.d/ido2db-pgsql': - source => '/usr/local/icinga-pgsql/etc/init.d/ido2db', - require => Cmmi['icinga-pgsql'] -} - -exec { 'populate-icinga-mysql-db': - unless => 'mysql -uicinga -picinga icinga -e "SELECT * FROM icinga_dbversion;" &> /dev/null', - command => "mysql -uroot icinga < /usr/local/src/icinga-mysql/icinga-${icingaVersion}/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', - command => "sudo -u postgres psql -U icinga -d icinga < /usr/local/src/icinga-pgsql/icinga-${icingaVersion}/module/idoutils/db/pgsql/pgsql.sql", - require => [ Cmmi['icinga-pgsql'], Exec['create-pgsql-icinga-db'] ] -} - -service { 'icinga-mysql': - ensure => running, - require => File['/etc/init.d/icinga-mysql'] -} - -service { 'ido2db-mysql': - ensure => running, - require => File['/etc/init.d/ido2db-mysql'] -} - -file { '/usr/local/icinga-mysql/etc/ido2db.cfg': - content => template('icinga/ido2db-mysql.cfg.erb'), - owner => 'icinga', - group => 'icinga', - require => Cmmi['icinga-mysql'], - notify => [ Service['icinga-mysql'], Service['ido2db-mysql'] ] -} - -file { '/usr/local/icinga-mysql/etc/idomod.cfg': - source => '/usr/local/icinga-mysql/etc/idomod.cfg-sample', - owner => 'icinga', - group => 'icinga', - require => Cmmi['icinga-mysql'], - notify => [ Service['icinga-mysql'], Service['ido2db-mysql'] ] -} - -file { '/usr/local/icinga-mysql/etc/modules/idoutils.cfg': - source => '/usr/local/icinga-mysql/etc/modules/idoutils.cfg-sample', - owner => 'icinga', - group => 'icinga', - require => Cmmi['icinga-mysql'], - notify => [ Service['icinga-mysql'], Service['ido2db-mysql'] ] -} - -service { 'icinga-pgsql': - ensure => running, - require => Cmmi['icinga-pgsql'] -} - -service { 'ido2db-pgsql': - ensure => running, - require => Cmmi['icinga-pgsql'] -} - -file { '/usr/local/icinga-pgsql/etc/ido2db.cfg': - content => template('icinga/ido2db-pgsql.cfg.erb'), - owner => 'icinga', - group => 'icinga', - require => Cmmi['icinga-pgsql'], - notify => [ Service['icinga-pgsql'], Service['ido2db-pgsql'] ] -} - -file { '/usr/local/icinga-pgsql/etc/idomod.cfg': - source => '/usr/local/icinga-pgsql/etc/idomod.cfg-sample', - owner => 'icinga', - group => 'icinga', - require => Cmmi['icinga-pgsql'], - notify => [ Service['icinga-pgsql'], Service['ido2db-pgsql'] ] -} - -file { '/usr/local/icinga-pgsql/etc/modules/idoutils.cfg': - source => '/usr/local/icinga-pgsql/etc/modules/idoutils.cfg-sample', - owner => 'icinga', - group => 'icinga', - require => Cmmi['icinga-pgsql'], - notify => [ Service['icinga-pgsql'], Service['ido2db-pgsql'] ] -} - -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 -p /usr/share/icinga && htpasswd -b -c /usr/share/icinga/htpasswd.users icingaadmin icinga', - require => Class['apache'] -} - -include monitoring-plugins - -cmmi { 'mk-livestatus': - url => "http://mathias-kettner.de/download/mk-livestatus-${livestatusVersion}.tar.gz", - output => "mk-livestatus-${livestatusVersion}.tar.gz", - flags => '--prefix=/usr/local/icinga-mysql --exec-prefix=/usr/local/icinga-mysql', - creates => '/usr/local/icinga-mysql/lib/mk-livestatus', - make => 'make && make install', - require => Cmmi['icinga-mysql'] -} - -file { '/usr/local/icinga-mysql/etc/modules/mk-livestatus.cfg': - content => template('mk-livestatus/mk-livestatus.cfg.erb'), - owner => 'icinga', - group => 'icinga', - require => Cmmi['mk-livestatus'], - notify => [ Service['icinga-mysql'], Service['ido2db-mysql'] ] -} - -file { 'openldap/db.ldif': - path => '/usr/share/openldap-servers/db.ldif', - source => 'puppet:///modules/openldap/db.ldif', - require => Class['openldap'] -} - -file { 'openldap/dit.ldif': - path => '/usr/share/openldap-servers/dit.ldif', - source => 'puppet:///modules/openldap/dit.ldif', - require => Class['openldap'] -} - -file { 'openldap/users.ldif': - path => '/usr/share/openldap-servers/users.ldif', - source => 'puppet:///modules/openldap/users.ldif', - require => Class['openldap'] -} - -exec { 'populate-openldap': - # TODO: Split the command and use unless instead of trying to populate openldap everytime - 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'], - File['openldap/dit.ldif'], File['openldap/users.ldif'] ] -} - -class { 'phantomjs': - url => "https://phantomjs.googlecode.com/files/phantomjs-${phantomjsVersion}-linux-x86_64.tar.bz2", - output => "phantomjs-${phantomjsVersion}-linux-x86_64.tar.bz2", - creates => '/usr/local/phantomjs' -} - -class { 'casperjs': - url => "https://github.com/n1k0/casperjs/tarball/${casperjsVersion}", - output => "casperjs-${casperjsVersion}.tar.gz", - creates => '/usr/local/casperjs' -} - -file { '/etc/profile.d/env.sh': - source => 'puppet:////vagrant/.vagrant-puppet/files/etc/profile.d/env.sh' -} - -include epel - -exec { 'install PHPUnit': - command => 'yum -d 0 -e 0 -y --enablerepo=epel install php-phpunit-PHPUnit', - unless => 'rpm -qa | grep php-phpunit-PHPUnit', - require => Class['epel'] -} - -exec { 'install PHP CodeSniffer': - command => 'yum -d 0 -e 0 -y --enablerepo=epel install php-pear-PHP-CodeSniffer', - unless => 'rpm -qa | grep php-pear-PHP-CodeSniffer', - require => Class['epel'] -} - -exec { 'install nodejs': - command => 'yum -d 0 -e 0 -y --enablerepo=epel install npm', - unless => 'rpm -qa | grep ^npm', - require => Class['epel'] -} - -exec { 'install npm/mocha': - command => 'npm install -g mocha', - creates => '/usr/lib/node_modules/mocha', - require => Exec['install nodejs'] -} - -exec { 'install npm/mocha-cobertura-reporter': - command => 'npm install -g mocha-cobertura-reporter', - creates => '/usr/lib/node_modules/mocha-cobertura-reporter', - require => Exec['install npm/mocha'] -} - -exec { 'install npm/jshint': - command => 'npm install -g jshint', - creates => '/usr/lib/node_modules/jshint', - require => Exec['install nodejs'] -} - -exec { 'install npm/expect': - command => 'npm install -g expect', - creates => '/usr/lib/node_modules/expect', - require => Exec['install nodejs'] -} - -exec { 'install npm/should': - command => 'npm install -g should', - creates => '/usr/lib/node_modules/should', - require => Exec['install nodejs'] -} - -exec { 'install npm/URIjs': - command => 'npm install -g URIjs', - creates => '/usr/lib/node_modules/URIjs', - require => Exec['install nodejs'] -} - -exec { 'install php-ZendFramework': - command => 'yum -d 0 -e 0 -y --enablerepo=epel install php-ZendFramework', - unless => 'rpm -qa | grep php-ZendFramework', - require => Class['epel'] -} - -package { ['cmake', 'boost-devel', 'bison', 'flex']: - ensure => installed -} - -# icinga 2 -define icinga2::feature ($feature = $title) { - exec { "icinga2-feature-${feature}": - path => '/bin:/usr/bin:/sbin:/usr/sbin', - unless => "readlink /etc/icinga2/features-enabled/${feature}.conf", - command => "icinga2-enable-feature ${feature}", - require => [ Package['icinga2'] ], - notify => Service['icinga2'] - } -} - -yumrepo { 'icinga2-repo': - baseurl => "http://packages.icinga.org/epel/6/snapshot/", - enabled => '1', - gpgcheck => '1', - gpgkey => 'http://packages.icinga.org/icinga.key', - descr => "Icinga Repository - ${::architecture}" -} - -exec { 'install nagios-plugins-all': - command => 'yum -d 0 -e 0 -y --enablerepo=epel install nagios-plugins-all', - unless => 'rpm -qa | grep nagios-plugins-all', - require => [ Class['epel'], Package['icinga2'] ], -} - -package { 'icinga2': - ensure => latest, - require => Yumrepo['icinga2-repo'], - alias => 'icinga2' -} - -package { 'icinga2-bin': - ensure => latest, - require => [ Yumrepo['icinga2-repo'], Package['icinga2'] ], - alias => 'icinga2-bin' -} - -package { 'icinga2-doc': - ensure => latest, - require => Yumrepo['icinga2-repo'], - alias => 'icinga2-doc' -} - -# icinga 2 classic ui -package { 'icinga2-classicui-config': - ensure => latest, - before => Package["icinga-gui"], - require => [ Yumrepo['icinga2-repo'], Package['icinga2'] ], - notify => Service['apache'] -} - -package { 'icinga-gui': - ensure => latest, - require => Yumrepo['icinga2-repo'], - alias => 'icinga-gui' -} - -icinga2::feature { 'statusdata': - require => Package['icinga2-classicui-config'] -} - -icinga2::feature { 'command': - require => Package['icinga2-classicui-config'] -} - -icinga2::feature { 'compatlog': - require => Package['icinga2-classicui-config'] -} - -# icinga 2 ido mysql -package { 'icinga2-ido-mysql': - ensure => latest, - require => Yumrepo['icinga2-repo'], - alias => 'icinga2-ido-mysql' -} - -exec { 'populate-icinga2-mysql-db': - unless => 'mysql -uicinga2 -picinga2 icinga2 -e "SELECT * FROM icinga_dbversion;" &> /dev/null', - command => 'mysql -uroot icinga2 < /usr/share/icinga2-ido-mysql/schema/mysql.sql', - require => [ Exec['create-mysql-icinga2-db'], Package['icinga2-ido-mysql'] ] -} - -file { '/etc/icinga2/features-available/ido-mysql.conf': - source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icinga2/features-available/ido-mysql.conf', - owner => 'icinga', - group => 'icinga', - require => Package['icinga2'], - notify => Service['icinga2'] -} - -file { '/etc/icinga2/features-enabled/ido-mysql.conf': - ensure => 'link', - target => '/etc/icinga2/features-available/ido-mysql.conf', - owner => 'root', - group => 'root', - require => Package['icinga2-ido-mysql'] -} - -icinga2::feature { 'ido-mysql': - require => Exec['populate-icinga2-mysql-db'] -} - - -# icinga 2 test config -file { '/etc/icinga2/conf.d/test-config.conf': - source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icinga2/conf.d/test-config.conf', - owner => 'icinga', - group => 'icinga', - require => [ Package['icinga2'], Exec['create_monitoring_test_config'] ] -} - -file { '/etc/icinga2/conf.d/commands.conf': - source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icinga2/conf.d/commands.conf', - owner => 'icinga', - group => 'icinga', - require => Package['icinga2'] -} - -file { '/etc/icinga2/constants.conf': - source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icinga2/constants.conf', - owner => 'icinga', - group => 'icinga', - require => Package['icinga2'] -} - -service { 'icinga2': - ensure => running, - require => [ - Package['icinga2'], - File['/etc/icinga2/features-enabled/ido-mysql.conf'], - File['/etc/icinga2/conf.d/test-config.conf'], - File['/etc/icinga2/conf.d/commands.conf'] - ] -} - -exec { 'install php-ZendFramework-Db-Adapter-Pdo-Mysql': - command => 'yum -d 0 -e 0 -y --enablerepo=epel install php-ZendFramework-Db-Adapter-Pdo-Mysql', - unless => 'rpm -qa | grep php-ZendFramework-Db-Adapter-Pdo-Mysql', - require => Exec['install php-ZendFramework'] -} - -file { '/etc/motd': - source => 'puppet:////vagrant/.vagrant-puppet/files/etc/motd', - owner => root, - group => root -} - -user { 'vagrant': - groups => 'icinga-cmd', - require => Group['icinga-cmd'] -} - -exec { 'create-mysql-icinga_unittest-db': - unless => 'mysql -uicinga_unittest -picinga_unittest icinga_unittest', - command => 'mysql -uroot -e "CREATE DATABASE icinga_unittest; \ - GRANT ALL ON icinga_unittest.* TO icinga_unittest@localhost \ - IDENTIFIED BY \'icinga_unittest\';"', - require => Service['mysqld'] -} - -exec{ 'create-pgsql-icinga_unittest-db': - unless => 'sudo -u postgres psql -tAc "SELECT 1 FROM pg_roles WHERE rolname=\'icinga_unittest\'" | grep -q 1', - command => 'sudo -u postgres psql -c "CREATE ROLE icinga_unittest WITH LOGIN PASSWORD \'icinga_unittest\';" && \ - sudo -u postgres createdb -O icinga_unittest -E UTF8 -T template0 icinga_unittest && \ - sudo -u postgres createlang plpgsql icinga_unittest', - require => Service['postgresql'] -} - -exec { 'install php-ZendFramework-Db-Adapter-Pdo-Pgsql': - command => 'yum -d 0 -e 0 -y --enablerepo=epel install php-ZendFramework-Db-Adapter-Pdo-Pgsql', - unless => 'rpm -qa | grep php-ZendFramework-Db-Adapter-Pdo-Pgsql', - require => Exec['install php-ZendFramework'] -} - - -# -# Following section installs the Perl module Monitoring::Generator::TestConfig in order to create test config to -# */usr/local/share/misc/monitoring_test_config*. Then the config is copied to */etc/conf.d/test_config/* of -# both the MySQL and PostgreSQL Icinga instance -# -cpan { 'Monitoring::Generator::TestConfig': - creates => '/usr/local/share/perl5/Monitoring/Generator/TestConfig.pm', - timeout => 600 -} - -exec { 'create_monitoring_test_config': - command => 'sudo install -o root -g root -d /usr/local/share/misc/ && \ - sudo /usr/local/bin/create_monitoring_test_config.pl -l icinga \ - /usr/local/share/misc/monitoring_test_config', - creates => '/usr/local/share/misc/monitoring_test_config', - require => Cpan['Monitoring::Generator::TestConfig'] -} - -define populate_monitoring_test_config { - file { "/usr/local/icinga-mysql/etc/conf.d/test_config/${name}.cfg": - owner => 'icinga', - group => 'icinga', - source => "/usr/local/share/misc/monitoring_test_config/etc/conf.d/${name}.cfg", - notify => Service['icinga-mysql'] - } - file { "/usr/local/icinga-pgsql/etc/conf.d/test_config/${name}.cfg": - owner => 'icinga', - group => 'icinga', - source => "/usr/local/share/misc/monitoring_test_config/etc/conf.d/${name}.cfg", - notify => Service['icinga-pgsql'] - } -} - -file { '/usr/local/icinga-mysql/etc/conf.d/test_config/': - ensure => directory, - owner => icinga, - group => icinga, - require => Cmmi['icinga-mysql'] -} - -file { '/usr/local/icinga-pgsql/etc/conf.d/test_config/': - ensure => directory, - owner => icinga, - group => icinga, - require => Cmmi['icinga-pgsql'] -} - -populate_monitoring_test_config { ['commands', 'contacts', 'dependencies', - 'hostgroups', 'hosts', 'servicegroups', 'services']: - require => [ Exec['create_monitoring_test_config'], - File['/usr/local/icinga-mysql/etc/conf.d/test_config/'], - File['/usr/local/icinga-pgsql/etc/conf.d/test_config/'] ] -} - -define populate_monitoring_test_config_plugins { - file { "/usr/lib64/nagios/plugins/${name}": - owner => 'icinga', - group => 'icinga', - source => "/usr/local/share/misc/monitoring_test_config/plugins/${name}", - notify => [ Service['icinga-mysql'], Service['icinga-pgsql'] ] - } -} - -populate_monitoring_test_config_plugins{ ['test_hostcheck.pl', 'test_servicecheck.pl']: - require => [ Exec['create_monitoring_test_config'], - Cmmi['icinga-mysql'], - Cmmi['icinga-pgsql'] ] -} - -# -# Following section creates and populates MySQL and PostgreSQL Icinga Web 2 databases -# -exec { 'create-mysql-icingaweb-db': - unless => 'mysql -uicingaweb -picingaweb icingaweb', - command => 'mysql -uroot -e "CREATE DATABASE icingaweb; \ - GRANT ALL ON icingaweb.* TO icingaweb@localhost \ - IDENTIFIED BY \'icingaweb\';"', - 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 -T template0 icingaweb && \ - sudo -u postgres createlang plpgsql icingaweb', - require => Service['postgresql'] -} - -exec { 'populate-icingaweb-mysql-db-tables': - unless => 'mysql -uicingaweb -picingaweb icingaweb -e "SELECT * FROM icingaweb_group;" &> /dev/null', - command => 'mysql -uicingaweb -picingaweb icingaweb < /vagrant/etc/schema/mysql.schema.sql', - require => [ Exec['create-mysql-icingaweb-db'] ] -} - -exec { 'populate-icingweba-pgsql-db-tables': - unless => 'psql -U icingaweb -d icingaweb -c "SELECT * FROM icingaweb_group;" &> /dev/null', - command => 'sudo -u postgres psql -U icingaweb -d icingaweb -f /vagrant/etc/schema/pgsql.schema.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'] ] -} - -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'] -} - -cmmi { 'icinga-web': - url => 'http://sourceforge.net/projects/icinga/files/icinga-web/1.10.0-beta/icinga-web-1.10.0-beta.tar.gz/download', - output => 'icinga-web-1.10.0-beta.tar.gz', - flags => '--prefix=/usr/local/icinga-web', - creates => '/usr/local/icinga-web', - make => 'make install && make install-apache-config', - require => Service['icinga_command_proxy'], - notify => Service['apache'] -} - -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/local/src/icinga-web/icinga-web-1.10.0-beta/etc/schema/mysql.sql', - require => [ Exec['create-mysql-icinga_web-db'], Cmmi['icinga-web'] ] -} - -file { '/var/www/html/icingaweb': - ensure => absent, -} - -file { '/etc/httpd/conf.d/icingaweb.conf': - source => 'puppet:////vagrant/.vagrant-puppet/files/etc/httpd/conf.d/icingaweb.conf', - require => Package['apache'], - notify => Service['apache'] -} - -file { '/etc/icingaweb': - ensure => 'directory', - owner => 'apache', - group => 'apache' -} - -file { '/etc/icingaweb/preferences': - ensure => 'directory', - owner => 'apache', - group => 'apache', - require => File['/etc/icingaweb'] -} - -file { '/etc/icingaweb/authentication.ini': - source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icingaweb/authentication.ini', - owner => 'apache', - group => 'apache', - require => File['/etc/icingaweb'] -} - -file { '/etc/icingaweb/config.ini': - ensure => file, - owner => 'apache', - group => 'apache', -} - -file { '/etc/icingaweb/resources.ini': - source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icingaweb/resources.ini', - owner => 'apache', - group => 'apache', - replace => false -} - -file { ['/etc/icingaweb/enabledModules', '/etc/icingaweb/modules', '/etc/icingaweb/modules/monitoring']: - ensure => 'directory', - owner => 'apache', - group => 'apache', -} - -file { '/etc/icingaweb/modules/monitoring/backends.ini': - source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icingaweb/modules/monitoring/backends.ini', - owner => 'apache', - group => 'apache', -} - -file { '/etc/icingaweb/modules/monitoring/config.ini': - source => 'puppet:////vagrant/config/modules/monitoring/config.ini', - owner => 'apache', - group => 'apache', -} - -file { '/etc/icingaweb/modules/monitoring/instances.ini': - source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icingaweb/modules/monitoring/instances.ini', - owner => 'apache', - group => 'apache', -} - -# pear::package { 'deepend/Mockery': -# channel => 'pear.survivethedeepend.com' -# } - -# icingacli -file { '/usr/local/bin/icingacli': - ensure => 'link', - target => '/vagrant/bin/icingacli', - owner => 'apache', - group => 'apache', - require => [ File['/etc/icingaweb'], File['/etc/bash_completion.d/icingacli'] ] -} - -exec { 'install bash-completion': - command => 'yum -d 0 -e 0 -y --enablerepo=epel install bash-completion', - unless => 'rpm -qa | grep bash-completion', - require => Class['epel'] -} - -file { '/etc/bash_completion.d/icingacli': - source => 'puppet:////vagrant/etc/bash_completion.d/icingacli', - owner => 'root', - group => 'root', - mode => 755, - require => Exec['install bash-completion'] -} diff --git a/.vagrant-puppet/manifests/finalize.sh b/.vagrant-puppet/manifests/finalize.sh deleted file mode 100644 index 3b1418575..000000000 --- a/.vagrant-puppet/manifests/finalize.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -set -e - -installJquery () { - # The npm module jquery won't install via puppet because of an mysterious error - # when node-gyp rebuilding the dependent contextify module - if [ ! -d /usr/lib/node_modules/jquery ]; then - npm install --silent -g jquery - fi -} - -startServicesWithNonLSBCompliantExitStatusCodes () { - # Unfortunately the ido2db init script is not LSB compliant and hence not started via puppet - service ido2db-mysql start || true - service ido2db-pgsql start || true -} - -mountIcinga2webVarLog () { - if ! $(/bin/mount | /bin/grep -q "/vagrant/var/log"); then - # Remount /vagrant/var/log/ with appropriate permissions since the group apache is missing initially - /bin/mount -t vboxsf -o \ - uid=`id -u vagrant`,gid=`id -g apache`,dmode=775,fmode=664 \ - /vagrant/var/log/ \ - /vagrant/var/log/ - fi -} - -installJquery -startServicesWithNonLSBCompliantExitStatusCodes -mountIcinga2webVarLog - -exit 0 diff --git a/.vagrant-puppet/modules/casperjs/manifests/init.pp b/.vagrant-puppet/modules/casperjs/manifests/init.pp deleted file mode 100644 index fd54e37f9..000000000 --- a/.vagrant-puppet/modules/casperjs/manifests/init.pp +++ /dev/null @@ -1,66 +0,0 @@ -# Class: casperjs -# -# This module downloads, extracts, and installs casperjs tar.gz archives -# using wget and tar. -# -# Parameters: -# [*url*] - fetch archive via wget from this url. -# [*output*] - filename to fetch the archive into. -# [*creates*] - target directory the software will install to. -# -# Actions: -# -# Requires: -# -# Sample Usage: -# -# class {'casperjs': -# url => 'https://github.com/n1k0/casperjs/tarball/1.0.2', -# output => 'casperjs-1.0.2.tar.gz', -# creates => '/usr/local/casperjs' -# } -# -class casperjs( - $url, - $output, - $creates -) { - - Exec { path => '/usr/bin:/bin' } - - $cwd = '/usr/local/src' - - include wget - - exec { 'download-casperjs': - cwd => $cwd, - command => "wget -q ${url} -O ${output}", - creates => "${cwd}/${output}", - timeout => 120, - require => Class['wget'] - } - - $tld = inline_template('<%= File.basename(@output, ".tar.bz2") %>') - $src = "${cwd}/casperjs" - - exec { 'extract-casperjs': - cwd => $cwd, - command => "mkdir -p casperjs && tar --no-same-owner \ - --no-same-permissions -xzf ${output} -C ${src} \ - --strip-components 1", - creates => $src, - require => Exec['download-casperjs'] - } - - file { 'install-casperjs': - path => $creates, - source => $src, - recurse => true, - require => Exec['extract-casperjs'] - } - - file { 'link-casperjs-bin': - ensure => "${creates}/bin/casperjs", - path => '/usr/local/bin/casperjs' - } -} diff --git a/.vagrant-puppet/modules/cmmi/manifests/init.pp b/.vagrant-puppet/modules/cmmi/manifests/init.pp deleted file mode 100644 index e0116fbc9..000000000 --- a/.vagrant-puppet/modules/cmmi/manifests/init.pp +++ /dev/null @@ -1,80 +0,0 @@ -# Define: cmmi -# -# This module downloads, extracts, builds and installs tar.gz archives using -# wget, tar and the autotools stack. Build directory is always /usr/local/src. -# -# *Note* make sure to install build essentials before running cmmi. -# -# Parameters: -# [*url*] - fetch archive via wget from this url. -# [*output*] - filename to fetch the archive into. -# [*flags*] - configure options. -# [*creates*] - target directory the software will install to. -# [*make* ] - command to make and make install the software. -# [*make_timeout* ] - timeout for the make command. -# -# Actions: -# -# Requires: -# -# Sample Usage: -# -# cmmi { 'example-software': -# url => 'http://example-software.com/download/', -# output => 'example-software.tar.gz', -# flags => '--prefix=/opt/example-software', -# creates => '/opt/example-software', -# make => 'make && make install' -# make_timeout => 600 -# } -# -define cmmi( - $url, - $output, - $flags='', - $creates, - $make, - $make_timeout=300, - $configure_command='sh ./configure' -) { - - Exec { path => '/bin:/usr/bin' } - - $cwd = '/usr/local/src' - - include wget - - exec { "download-${name}": - cwd => $cwd, - command => "wget -q \"${url}\" -O ${output}", - creates => "${cwd}/${output}", - require => Class['wget'] - } - - $tld = inline_template('<%= File.basename(@output, ".tar.gz") %>') - $src = "${cwd}/${name}/${tld}" - - exec { "extract-${name}": - cwd => $cwd, - command => "mkdir -p ${name}/${tld} && tar --no-same-owner \ - --no-same-permissions -xzf ${output} -C ${name}/${tld} \ - --strip-components 1", - creates => $src, - require => Exec["download-${name}"] - } - - exec { "configure-${name}": - cwd => $src, - command => "${configure_command} ${flags}", - creates => "${src}/Makefile", - require => Exec["extract-${name}"] - } - - exec { "make-${name}": - cwd => $src, - command => $make, - creates => $creates, - require => Exec["configure-${name}"], - timeout => $make_timeout - } -} diff --git a/.vagrant-puppet/modules/configure/manifests/init.pp b/.vagrant-puppet/modules/configure/manifests/init.pp deleted file mode 100644 index beeb98b17..000000000 --- a/.vagrant-puppet/modules/configure/manifests/init.pp +++ /dev/null @@ -1,17 +0,0 @@ -# Define: configure -# -# Run a gnu configure to prepare software for environment -# -# Parameters: -# [*flags*] - configure options. -# [*path*] - Target and working dir -# -define configure( - $path, - $flags -) { - exec { "configure-${name}": - cwd => $path, - command => "sh ./configure ${flags}" - } -} \ No newline at end of file diff --git a/.vagrant-puppet/modules/cpan/manifests/init.pp b/.vagrant-puppet/modules/cpan/manifests/init.pp deleted file mode 100644 index 9cbdaf8b0..000000000 --- a/.vagrant-puppet/modules/cpan/manifests/init.pp +++ /dev/null @@ -1,49 +0,0 @@ -# Define: cpan -# -# Download and install Perl modules from the Perl Archive Network, the canonical location for Perl code and modules. -# -# Parameters: -# [*creates*] - target directory the software will install to. -# [*timeout* ] - timeout for the CPAN command. -# -# Actions: -# -# Requires: -# -# Perl -# -# Sample Usage: -# -# cpan { 'perl-module': -# creates => '/usr/local/share/perl5/perl-module', -# timeout => 600 -# } -# -define cpan( - $creates, - $timeout -) { - - Exec { path => '/usr/bin' } - - package { 'perl-CPAN': - ensure => installed - } - - file { [ '/root/.cpan/', '/root/.cpan/CPAN/' ]: - ensure => directory - } - - file { '/root/.cpan/CPAN/MyConfig.pm': - content => template('cpan/MyConfig.pm.erb'), - require => [ Package['perl-CPAN'], - File[[ '/root/.cpan/', '/root/.cpan/CPAN/' ]] ] - } - - exec { "cpan-${name}": - command => "sudo perl -MCPAN -e 'install ${name}'", - creates => $creates, - require => File['/root/.cpan/CPAN/MyConfig.pm'], - timeout => $timeout - } -} diff --git a/.vagrant-puppet/modules/cpan/templates/MyConfig.pm.erb b/.vagrant-puppet/modules/cpan/templates/MyConfig.pm.erb deleted file mode 100644 index da410a188..000000000 --- a/.vagrant-puppet/modules/cpan/templates/MyConfig.pm.erb +++ /dev/null @@ -1,68 +0,0 @@ -$CPAN::Config = { - 'applypatch' => q[], - 'auto_commit' => q[0], - 'build_cache' => q[100], - 'build_dir' => q[/root/.cpan/build], - 'build_dir_reuse' => q[0], - 'build_requires_install_policy' => q[ask/yes], - 'bzip2' => q[/usr/bin/bzip2], - 'cache_metadata' => q[1], - 'check_sigs' => q[0], - 'commandnumber_in_prompt' => q[1], - 'connect_to_internet_ok' => q[1], - 'cpan_home' => q[/root/.cpan], - 'curl' => q[/usr/bin/curl], - 'ftp' => q[], - 'ftp_passive' => q[1], - 'ftp_proxy' => q[], - 'getcwd' => q[cwd], - 'gpg' => q[/usr/bin/gpg], - 'gzip' => q[/bin/gzip], - 'halt_on_failure' => q[0], - 'histfile' => q[/root/.cpan/histfile], - 'histsize' => q[100], - 'http_proxy' => q[], - 'inactivity_timeout' => q[0], - 'index_expire' => q[1], - 'inhibit_startup_message' => q[0], - 'keep_source_where' => q[/root/.cpan/sources], - 'load_module_verbosity' => q[v], - 'lynx' => q[], - 'make' => q[/usr/bin/make], - 'make_arg' => q[], - 'make_install_arg' => q[], - 'make_install_make_command' => q[/usr/bin/make], - 'makepl_arg' => q[INSTALLDIRS=site], - 'mbuild_arg' => q[], - 'mbuild_install_arg' => q[], - 'mbuild_install_build_command' => q[./Build], - 'mbuildpl_arg' => q[--installdirs site], - 'ncftp' => q[], - 'ncftpget' => q[], - 'no_proxy' => q[], - 'pager' => q[/usr/bin/less], - 'patch' => q[], - 'perl5lib_verbosity' => q[v], - 'prefer_installer' => q[MB], - 'prefs_dir' => q[/root/.cpan/prefs], - 'prerequisites_policy' => q[follow], - 'scan_cache' => q[atstart], - 'shell' => q[/bin/bash], - 'show_unparsable_versions' => q[0], - 'show_upload_date' => q[0], - 'show_zero_versions' => q[0], - 'tar' => q[/bin/tar], - 'tar_verbosity' => q[v], - 'term_is_latin' => q[1], - 'term_ornaments' => q[1], - 'test_report' => q[0], - 'trust_test_report_history' => q[0], - 'unzip' => q[/usr/bin/unzip], - 'urllist' => [], - 'use_sqlite' => q[0], - 'wget' => q[/usr/bin/wget], - 'yaml_load_code' => q[0], - 'yaml_module' => q[YAML], -}; -1; -__END__ diff --git a/.vagrant-puppet/modules/mk-livestatus/templates/mk-livestatus.cfg.erb b/.vagrant-puppet/modules/mk-livestatus/templates/mk-livestatus.cfg.erb deleted file mode 100644 index f61ffc001..000000000 --- a/.vagrant-puppet/modules/mk-livestatus/templates/mk-livestatus.cfg.erb +++ /dev/null @@ -1,6 +0,0 @@ -define module{ - module_name mklivestatus - path /usr/local/icinga-mysql/lib/mk-livestatus/livestatus.o - module_type neb - args /usr/local/icinga-mysql/var/rw/live - } diff --git a/.vagrant-puppet/modules/pear/manifests/init.pp b/.vagrant-puppet/modules/pear/manifests/init.pp deleted file mode 100644 index 0c748f2bc..000000000 --- a/.vagrant-puppet/modules/pear/manifests/init.pp +++ /dev/null @@ -1,43 +0,0 @@ -# Class: pear -# -# This class installs pear. -# -# Parameters: -# -# Actions: -# -# Requires: -# -# php -# -# Sample Usage: -# -# include pear -# -class pear { - - Exec { path => '/usr/bin:/bin' } - - include php - - package { 'php-pear': - ensure => installed, - require => Class['php'] - } - - exec { 'pear upgrade': - command => 'pear upgrade', - require => Package['php-pear'] - } - - exec { 'pear update-channels': - command => 'pear update-channels', - require => Package['php-pear'] - } - - exec { 'pear auto discover channels': - command => 'pear config-set auto_discover 1', - unless => 'pear config-get auto_discover | grep 1', - require => Package['php-pear'] - } -} diff --git a/.vagrant-puppet/modules/pear/manifests/package.pp b/.vagrant-puppet/modules/pear/manifests/package.pp deleted file mode 100644 index 90b807b3d..000000000 --- a/.vagrant-puppet/modules/pear/manifests/package.pp +++ /dev/null @@ -1,50 +0,0 @@ -# Define: pear::package -# -# Install additional PEAR packages -# -# Parameters: -# -# Actions: -# -# Requires: -# -# pear -# -# Sample Usage: -# -# pear::package { 'phpunit': } -# -define pear::package( - $channel -) { - - Exec { path => '/usr/bin' } - - include pear - - if $::require { - $require_ = [Class['pear'], $::require] - } else { - $require_ = Class['pear'] - } - - if $channel { - exec { "pear discover ${channel}": - command => "sudo pear channel-discover ${channel}", - unless => "pear channel-info ${channel}", - require => $require_, - before => Exec["pear install ${name}"] - } - } - - exec { "pear install ${name}": - command => "pear install --alldeps ${name}", - unless => "pear list ${name}", - require => $require_ - } - - exec { "pear upgrade ${name}": - command => "pear upgrade ${name}", - require => Exec["pear install ${name}"] - } -} diff --git a/.vagrant-puppet/modules/phantomjs/manifests/init.pp b/.vagrant-puppet/modules/phantomjs/manifests/init.pp deleted file mode 100644 index ea65b1f26..000000000 --- a/.vagrant-puppet/modules/phantomjs/manifests/init.pp +++ /dev/null @@ -1,65 +0,0 @@ -# Class: phantomjs -# -# This module downloads, extracts, and installs phantomjs tar.bz2 archives -# using wget and tar. -# -# Parameters: -# [*url*] - fetch archive via wget from this url. -# [*output*] - filename to fetch the archive into. -# [*creates*] - target directory the software will install to. -# -# Actions: -# -# Requires: -# -# Sample Usage: -# -# class {'phantomjs': -# url => 'https://phantomjs.googlecode.com/files/phantomjs-1.9.1-linux-x86_64.tar.bz2', -# output => 'phantomjs-1.9.1-linux-x86_64.tar.bz2', -# creates => '/usr/local/phantomjs' -# } -# -class phantomjs( - $url, - $output, - $creates -) { - - Exec { path => '/usr/bin:/bin' } - - $cwd = '/usr/local/src' - - include wget - - exec { 'download-phantomjs': - cwd => $cwd, - command => "wget -q ${url} -O ${output}", - creates => "${cwd}/${output}", - timeout => 120, - require => Class['wget'] - } - - $src = "${cwd}/phantomjs" - - exec { 'extract-phantomjs': - cwd => $cwd, - command => "mkdir -p phantomjs && tar --no-same-owner \ - --no-same-permissions -xjf ${output} -C ${src} \ - --strip-components 1", - creates => $src, - require => Exec['download-phantomjs'] - } - - file { 'install-phantomjs': - path => $creates, - source => $src, - recurse => true, - require => Exec['extract-phantomjs'] - } - - file { 'link-phantomjs-bin': - ensure => "${creates}/bin/phantomjs", - path => '/usr/local/bin/phantomjs' - } -} diff --git a/.vagrant-puppet/modules/wget/manifests/init.pp b/.vagrant-puppet/modules/wget/manifests/init.pp deleted file mode 100644 index 560e10b2f..000000000 --- a/.vagrant-puppet/modules/wget/manifests/init.pp +++ /dev/null @@ -1,20 +0,0 @@ -# Class: wget -# -# This class installs wget. -# -# Parameters: -# -# Actions: -# -# Requires: -# -# Sample Usage: -# -# include wget -# -class wget { - - package { 'wget': - ensure => installed, - } -} diff --git a/Vagrantfile b/Vagrantfile index d73944173..28b69cab9 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -2,7 +2,7 @@ # vi: set ft=ruby : VAGRANTFILE_API_VERSION = "2" -VAGRANT_REQUIRED_VERSION = "1.2.0" +VAGRANT_REQUIRED_VERSION = "1.5.0" # Require 1.2.x at least if ! defined? Vagrant.require_version @@ -15,93 +15,36 @@ else end Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| - # All Vagrant configuration is done here. The most common configuration - # options are documented and commented below. For a complete reference, - # please see the online documentation at vagrantup.com. - - # Every Vagrant virtual environment requires a box to build off of. - config.vm.box = "centos-6.4-x64-vbox" - - # The url from where the 'config.vm.box' box will be fetched if it - # doesn't already exist on the user's system. - config.vm.box_url = "http://vagrant-boxes.icinga.org/centos-64-x64-vbox4212.box" - - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine. In the example below, - # accessing "localhost:8080" will access port 80 on the guest machine. - config.vm.network :forwarded_port, guest: 80, host: 8080, - # Port collision auto-correction must be manually enabled for each forwarded port, - # since it is often surprising when it occurs and can lead the Vagrant user to - # think that the port wasn't properly forwarded. During a vagrant up or vagrant reload, - # Vagrant will output information about any collisions detections and auto corrections made, - # so you can take notice and act accordingly. + config.vm.network "forwarded_port", guest: 80, host: 8080, auto_correct: true - # Create a private network, which allows host-only access to the machine - # using a specific IP. - # config.vm.network :private_network, ip: "192.168.33.10" + config.vm.provision :shell, :path => ".puppet/manifests/puppet.sh" - # Create a public network, which generally matched to bridged network. - # Bridged networks make the machine appear as another physical device on - # your network. - # config.vm.network :public_network + config.vm.provider :virtualbox do |v, override| + override.vm.box = "puppetlabs/centos-6.5-64-puppet" - # If true, then any SSH connections made will enable agent forwarding. - # Default value: false - # config.ssh.forward_agent = true - - # Share an additional folder to the guest VM. The first argument is - # the path on the host to the actual folder. The second argument is - # 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 "./var/log", "/vagrant/var/log" - - # Provider-specific configuration so you can fine-tune various - # backing providers for Vagrant. These expose provider-specific options. - # Example for VirtualBox: - # - # config.vm.provider :virtualbox do |vb| - # # Don't boot with headless mode - # vb.gui = true - # - # # Use VBoxManage to customize the VM. For example to change memory: - # vb.customize ["modifyvm", :id, "--memory", "1024"] - # end - # - # View the documentation for the provider you're using for more - # information on available options. - config.vm.provider "virtualbox" do |vb| - vb.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate//vagrant/config", "1"] - vb.customize ["modifyvm", :id, "--memory", "1024"] + v.customize ["modifyvm", :id, "--memory", "1024"] + end + + config.vm.provider :parallels do |p, override| + override.vm.box = "parallels/centos-6.5" + + p.name = "Icinga Web 2 Development" + + # Update Parallels Tools automatically + p.update_guest_tools = true + + # Set power consumption mode to "Better Performance" + p.optimize_power_consumption = false + + p.memory = 1024 + p.cpus = 2 end - # Enable provisioning with Puppet stand alone. Puppet manifests - # are contained in a directory path relative to this Vagrantfile. - # You will need to create the manifests directory and a manifest in - # the file base.pp in the manifests_path directory. - # - # An example Puppet manifest to provision the message of the day: - # - # # group { "puppet": - # # ensure => "present", - # # } - # # - # # File { owner => 0, group => 0, mode => 0644 } - # # - # # file { '/etc/motd': - # # content => "Welcome to your Vagrant-built virtual machine! - # # Managed by Puppet.\n" - # # } - # - # config.vm.provision :puppet do |puppet| - # puppet.manifests_path = "manifests" - # puppet.manifest_file = "init.pp" - # end config.vm.provision :puppet do |puppet| - puppet.module_path = ".vagrant-puppet/modules" - puppet.manifests_path = ".vagrant-puppet/manifests" - # puppet.options = "-v -d" + puppet.hiera_config_path = ".puppet/hiera/hiera.yaml" + puppet.module_path = [ ".puppet/modules", ".puppet/profiles" ] + puppet.manifests_path = ".puppet/manifests" + puppet.manifest_file = "site.pp" end - - config.vm.provision :shell, :path => ".vagrant-puppet/manifests/finalize.sh" end diff --git a/Vagrantfile.parallels b/Vagrantfile.parallels deleted file mode 100644 index 551345f2b..000000000 --- a/Vagrantfile.parallels +++ /dev/null @@ -1,27 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -Vagrant.configure("2") do |config| - config.vm.box = "parallels/centos-6.5" - - config.vm.network "forwarded_port", guest: 80, host: 8080, - auto_correct: true - - config.vm.provider "parallels" do |v| - v.name = "Icinga Web 2 Development" - # Update Parallels Tools automatically - v.update_guest_tools = true - # Set power consumption mode to "Better Performance" - v.optimize_power_consumption = false - v.memory = 1024 - v.cpus = 2 - end - - config.puppet_install.puppet_version = :latest - - config.vm.provision :puppet do |puppet| - puppet.module_path = ".vagrant-puppet/modules" - puppet.manifests_path = ".vagrant-puppet/manifests" - # puppet.options = "-v -d" - end -end diff --git a/application/controllers/AuthenticationController.php b/application/controllers/AuthenticationController.php index 00dae1c6d..2d7926819 100644 --- a/application/controllers/AuthenticationController.php +++ b/application/controllers/AuthenticationController.php @@ -4,16 +4,17 @@ # namespace Icinga\Application\Controllers; -use Icinga\Authentication\Backend\AutoLoginBackend; -use Icinga\Web\Controller\ActionController; -use Icinga\Forms\Authentication\LoginForm; -use Icinga\Authentication\AuthChain; use Icinga\Application\Config; +use Icinga\Application\Icinga; use Icinga\Application\Logger; +use Icinga\Authentication\AuthChain; +use Icinga\Authentication\Backend\AutoLoginBackend; use Icinga\Exception\AuthenticationException; -use Icinga\Exception\NotReadableError; use Icinga\Exception\ConfigurationError; +use Icinga\Exception\NotReadableError; +use Icinga\Forms\Authentication\LoginForm; use Icinga\User; +use Icinga\Web\Controller\ActionController; use Icinga\Web\Url; /** @@ -33,7 +34,8 @@ class AuthenticationController extends ActionController */ public function loginAction() { - if (@file_exists(Config::resolvePath('setup.token')) && !@file_exists(Config::resolvePath('config.ini'))) { + $icinga = Icinga::app(); + if ($icinga->setupTokenExists() && $icinga->requiresSetup()) { $this->redirectNow(Url::fromPath('setup')); } @@ -139,7 +141,7 @@ class AuthenticationController extends ActionController $this->view->errorInfo = $e->getMessage(); } - $this->view->configMissing = is_dir(Config::$configDir) === false; + $this->view->requiresSetup = Icinga::app()->requiresSetup(); } /** diff --git a/application/forms/Config/Authentication/AutologinBackendForm.php b/application/forms/Config/Authentication/AutologinBackendForm.php index a21d2c006..97b5dfed7 100644 --- a/application/forms/Config/Authentication/AutologinBackendForm.php +++ b/application/forms/Config/Authentication/AutologinBackendForm.php @@ -53,8 +53,10 @@ class AutologinBackendForm extends Form 'strip_username_regexp', array( 'label' => t('Filter Pattern'), - 'description' => t('The regular expression to use to strip specific parts off from usernames. Leave empty if you do not want to strip off anything'), - 'value' => '/\@[^$]+$/', + 'description' => t( + 'The regular expression to use to strip specific parts off from usernames.' + . ' Leave empty if you do not want to strip off anything' + ), 'validators' => array( new Zend_Validate_Callback(function ($value) { return @preg_match($value, '') !== false; diff --git a/application/forms/Config/General/LoggingConfigForm.php b/application/forms/Config/General/LoggingConfigForm.php index deed06011..759c2a6e3 100644 --- a/application/forms/Config/General/LoggingConfigForm.php +++ b/application/forms/Config/General/LoggingConfigForm.php @@ -67,7 +67,7 @@ class LoggingConfigForm extends Form 'required' => true, 'label' => t('Application Prefix'), 'description' => t('The name of the application by which to prefix syslog messages.'), - 'value' => 'icingaweb', + 'value' => 'icingaweb2', 'validators' => array( array( 'Regex', @@ -106,7 +106,7 @@ class LoggingConfigForm extends Form 'required' => true, 'label' => t('File path'), 'description' => t('The full path to the log file to write messages to.'), - 'value' => $this->getDefaultLogDir(), + 'value' => '/var/log/icingaweb2/icingaweb2.log', 'validators' => array(new WritablePathValidator()) ) ); @@ -114,14 +114,4 @@ class LoggingConfigForm extends Form return $this; } - - /** - * Return the default logging directory for type 'file' - * - * @return string - */ - protected function getDefaultLogDir() - { - return realpath(Icinga::app()->getApplicationDir('../var/log/icingaweb.log')); - } } diff --git a/application/forms/Config/Resource/LivestatusResourceForm.php b/application/forms/Config/Resource/LivestatusResourceForm.php index d90600370..2262cf583 100644 --- a/application/forms/Config/Resource/LivestatusResourceForm.php +++ b/application/forms/Config/Resource/LivestatusResourceForm.php @@ -44,7 +44,7 @@ class LivestatusResourceForm extends Form 'required' => true, 'label' => t('Socket'), 'description' => t('The path to your livestatus socket used for querying monitoring data'), - 'value' => realpath(Icinga::app()->getApplicationDir() . '/../var/rw/livestatus') + 'value' => '/var/run/icinga2/cmd/livestatus' ) ); diff --git a/application/forms/Security/RoleForm.php b/application/forms/Security/RoleForm.php index 0fb53e858..b27a4ec8b 100644 --- a/application/forms/Security/RoleForm.php +++ b/application/forms/Security/RoleForm.php @@ -6,6 +6,7 @@ namespace Icinga\Forms\Security; use InvalidArgumentException; use LogicException; +use Zend_Form_Element; use Icinga\Application\Icinga; use Icinga\Forms\ConfigForm; use Icinga\Util\String; @@ -18,14 +19,14 @@ class RoleForm extends ConfigForm /** * Provided permissions by currently loaded modules * - * @var array + * @type array */ - protected $providedPermissions = array(); + protected $providedPermissions = array('*' => '*'); /** * Provided restrictions by currently loaded modules * - * @var array + * @type array */ protected $providedRestrictions = array(); @@ -35,14 +36,26 @@ class RoleForm extends ConfigForm */ public function init() { + $helper = new Zend_Form_Element('bogus'); foreach (Icinga::app()->getModuleManager()->getLoadedModules() as $module) { foreach ($module->getProvidedPermissions() as $permission) { - /** @var object $permission */ + /** @type object $permission */ $this->providedPermissions[$permission->name] = $permission->name . ': ' . $permission->description; } foreach ($module->getProvidedRestrictions() as $restriction) { - /** @var object $restriction */ - $this->providedRestrictions[$restriction->name] = $restriction->description; + /** @type object $restriction */ + $name = $helper->filterName($restriction->name); // Zend only permits alphanumerics, the underscore, + // the circumflex and any ASCII character in range + // \x7f to \xff (127 to 255) + while (isset($this->providedRestrictions[$name])) { + // Because Zend_Form_Element::filterName() replaces any not permitted character with the empty + // string we may have duplicate names, e.g. 're/striction' and 'restriction' + $name .= '_'; + } + $this->providedRestrictions[$name] = array( + 'description' => $restriction->description, + 'name' => $restriction->name + ); } } } @@ -90,13 +103,13 @@ class RoleForm extends ConfigForm ) ) )); - foreach ($this->providedRestrictions as $name => $description) { + foreach ($this->providedRestrictions as $name => $spec) { $this->addElement( 'text', $name, array( - 'label' => $name, - 'description' => $description + 'label' => $spec['name'], + 'description' => $spec['description'] ) ); } @@ -129,6 +142,15 @@ class RoleForm extends ConfigForm ? String::trimSplit($role['permissions']) : null; $role['name'] = $name; + $restrictions = array(); + foreach ($this->providedRestrictions as $name => $spec) { + if (isset($role[$spec['name']])) { + // Translate restriction names to filtered element names + $restrictions[$name] = $role[$spec['name']]; + unset($role[$spec['name']]); + } + } + $role = array_merge($role, $restrictions); $this->populate($role); return $this; } @@ -230,6 +252,15 @@ class RoleForm extends ConfigForm if (isset($values['permissions'])) { $values['permissions'] = implode(', ', $values['permissions']); } + $restrictions = array(); + foreach ($this->providedRestrictions as $name => $spec) { + if (isset($values[$name])) { + // Translate filtered element names to restriction names + $restrictions[$spec['name']] = $values[$name]; + unset($values[$name]); + } + } + $values = array_merge($values, $restrictions); return $values; } } diff --git a/application/layouts/scripts/pdf.phtml b/application/layouts/scripts/pdf.phtml index c4a1b25f7..38c9bdc2c 100644 --- a/application/layouts/scripts/pdf.phtml +++ b/application/layouts/scripts/pdf.phtml @@ -31,7 +31,7 @@ if ( isset($pdf) ) } -img('img/logo_icinga_big_dark.png', array('align' => 'right', 'width' => '150')) ?> +img('img/logo_icinga_big_dark.png', array('align' => 'right', 'width' => '75')) ?> - - monitoringState($host, 'host')) ?>
+ + host_state, true)); ?>
host_state !== 99): ?> prefixedTimeSince($host->host_last_state_change, true) ?> host_state > 0 && (int) $host->host_state_type === 0): ?> @@ -106,10 +108,9 @@ if ($hosts->count() === 0) { $host->host_unhandled_services), 'monitoring/show/services', array( - 'host' => $host->host_name, - 'service_problem' => 1, - 'service_acknowledged' => 0, - 'service_in_downtime' => 0 + 'host' => $host->host_name, + 'service_problem' => 1, + 'service_handled' => 0 ), array('style' => 'font-weight: normal') ) ?>) diff --git a/modules/monitoring/application/views/scripts/list/notifications.phtml b/modules/monitoring/application/views/scripts/list/notifications.phtml index 28c71c0b8..13736b9f3 100644 --- a/modules/monitoring/application/views/scripts/list/notifications.phtml +++ b/modules/monitoring/application/views/scripts/list/notifications.phtml @@ -1,3 +1,10 @@ + + compact): ?>
tabs ?> @@ -36,13 +43,13 @@ foreach ($notifications as $notification): 'host' => $notification->host, 'service' => $notification->service )); - $stateName = strtolower($this->util()->getServiceStateName($notification->notification_state)); + $stateName = Service::getStateText($notification->notification_state); } else { $isService = false; $href = $this->href('monitoring/show/host', array( 'host' => $notification->host )); - $stateName = strtolower($this->util()->getHostStateName($notification->notification_state)); + $stateName = Host::getStateText($notification->notification_state); } ?> diff --git a/modules/monitoring/application/views/scripts/list/servicegrid.phtml b/modules/monitoring/application/views/scripts/list/servicegrid.phtml index 19aef5d64..dd9be0394 100644 --- a/modules/monitoring/application/views/scripts/list/servicegrid.phtml +++ b/modules/monitoring/application/views/scripts/list/servicegrid.phtml @@ -1,3 +1,8 @@ + compact): ?>
tabs; ?> @@ -63,7 +68,7 @@ $hostFilter = '(host_name=' . implode('|host_name=', array_keys($pivotData)) . ' + )); ?>" title="escape($service->service_output); ?>" class="state_service_state); ?> service_handled ? 'handled' : ''; ?>"> · diff --git a/modules/monitoring/application/views/scripts/list/services.phtml b/modules/monitoring/application/views/scripts/list/services.phtml index 2ea125527..8ef6f7fe8 100644 --- a/modules/monitoring/application/views/scripts/list/services.phtml +++ b/modules/monitoring/application/views/scripts/list/services.phtml @@ -1,4 +1,8 @@ getHelper('MonitoringState'); $selfUrl = 'monitoring/list/services'; @@ -51,12 +55,11 @@ foreach ($services as $service): 'host' => $service->host_name, ) ); - $serviceStateName = strtolower($this->util()->getServiceStateName($service->service_state)); + $serviceStateName = Service::getStateText($service->service_state); ?> - - translate(strtoupper($helper->monitoringState($service, 'service'))) ?>
- + + service_state, true)); ?>
compact): ?>prefixedTimeSince($service->service_last_state_change); ?>timeSince($service->service_last_state_change); ?> service_state > 0 && (int) $service->service_state_type === 0): ?>
@@ -65,7 +68,7 @@ foreach ($services as $service): - perfdata($service->service_perfdata, true, true) ?> + perfdata($service->service_perfdata, true) ?> service_handled && $service->service_state > 0): ?> icon('attention-alt', $this->translate('Unhandled')) ?> @@ -106,7 +109,7 @@ foreach ($services as $service): service_display_name ?>showHost): ?> on host_name; ?> host_state != 0): ?> - (monitoringState($service, 'host')); ?>) + (host_state, true)); ?>)

escape(substr(strip_tags($service->service_output), 0, 10000)); ?>

diff --git a/modules/monitoring/application/views/scripts/multi/components/comments.phtml b/modules/monitoring/application/views/scripts/multi/components/comments.phtml deleted file mode 100644 index f0b262c9d..000000000 --- a/modules/monitoring/application/views/scripts/multi/components/comments.phtml +++ /dev/null @@ -1,25 +0,0 @@ -is_service ? 'Services' : 'Hosts'; - -?> - translate('Comments') ?> - - icon('cancel') - ?> translate('Remove Comments') ?>
- icon('bell-off-empty') - ?> translate('Delay Notifications') ?>
- - icon('ok') ?> Acknowledge - - - comments . - - diff --git a/modules/monitoring/application/views/scripts/multi/components/downtimes.phtml b/modules/monitoring/application/views/scripts/multi/components/downtimes.phtml deleted file mode 100644 index af8d841b4..000000000 --- a/modules/monitoring/application/views/scripts/multi/components/downtimes.phtml +++ /dev/null @@ -1,19 +0,0 @@ -is_service ? 'Services' : 'Hosts'; - -?> - - Downtimes - - icon('cancel') ?>Remove Downtimes
- icon('plug') - ?> Schedule Downtimes - - - Change downtimes. - - diff --git a/modules/monitoring/application/views/scripts/multi/components/flags.phtml b/modules/monitoring/application/views/scripts/multi/components/flags.phtml deleted file mode 100644 index 1269e2f49..000000000 --- a/modules/monitoring/application/views/scripts/multi/components/flags.phtml +++ /dev/null @@ -1,25 +0,0 @@ -
- - form->getElements() as $name => $element): - if ($element instanceof \Icinga\Web\Form\Element\TriStateCheckbox): - $element->setDecorators(array('ViewHelper')); - ?> - - - - - - - - - - - -
render() ?>
render() ?>
-
\ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/multi/components/objectlist.phtml b/modules/monitoring/application/views/scripts/multi/components/objectlist.phtml deleted file mode 100644 index 879a13a1d..000000000 --- a/modules/monitoring/application/views/scripts/multi/components/objectlist.phtml +++ /dev/null @@ -1,65 +0,0 @@ -is_service) { - $links[] = $this->qlink( - $object->host_name . ' ' . $object->service_description, - 'monitoring/show/service', - array( - 'host' => $object->host_name, - 'service' => $object->service_description - ) - ); - } else { - $links[] = $this->qlink( - $object->host_name, - 'monitoring/show/host', - array( - 'host' => $object->host_name - ) - ); - } -} - -if ($this->is_service) { - $objectName = $this->translate('Services'); - $link = 'monitoring/list/services'; - $target = array( - 'host' => $this->hostquery, - 'service' => $this->servicequery - ); -} else { - $objectName = $this->translate('Hosts'); - $link = 'monitoring/list/hosts'; - $target = array( - 'host' => $this->hostquery - ); -} - -$more = clone $this->url; - - -?> -qlink( - $this->translate('List all'), - $more->setPath($link), - null, - array('title' => $this->translate('List all selected objects')) -) ?> - - 5) { - echo ' ' . sprintf($this->translate('and %d more'), count($objects) - 5); -} - -?> - - diff --git a/modules/monitoring/application/views/scripts/multi/components/summary.phtml b/modules/monitoring/application/views/scripts/multi/components/summary.phtml deleted file mode 100644 index d832624c7..000000000 --- a/modules/monitoring/application/views/scripts/multi/components/summary.phtml +++ /dev/null @@ -1,59 +0,0 @@ -getHelper('CommandForm'); -$servicequery = isset($this->servicequery) ? $this->servicequery : ''; -$objectName = $this->is_service ? $this->translate('Services') : $this->translate('Hosts'); - -$params = array( - 'host' => $this->target['host'], - 'service' => null, - 'checktime' => time(), - 'forcecheck' => '1' -); -if (array_key_exists('service', $this->target)) { - $params['service'] = $this->target['service']; -} else { - unset($params['service']); -} -?> - - - - icon('rescheduel') - ?> Recheck
- icon('reschedule') - ?> Reschedule
- - Perform actions on . - - - - problems ?> Problems - - icon('plug') - ?> Schedule Downtimes - - problems, - count($this->objects), - $objectName - ) ?> - - - unhandled) ?> Unhandled - - icon('ok') - ?> Acknowledge
- icon('remove_petrol.png') ?> Remove Acknowledgements - - diff --git a/modules/monitoring/application/views/scripts/multi/host.phtml b/modules/monitoring/application/views/scripts/multi/host.phtml deleted file mode 100644 index 6179f6339..000000000 --- a/modules/monitoring/application/views/scripts/multi/host.phtml +++ /dev/null @@ -1,62 +0,0 @@ -is_service = false; -$this->hostquery = implode($this->hostnames, ','); -$this->target = array('host' => $this->hostquery); -?> - -
- tabs; ?> -
- -
- - - -

Summary for hosts

- render('multi/components/objectlist.phtml'); ?> - - - - - - - - - - -
-

Hosts

-
- pie->render(); ?> - - $count) { - if ($count > 0) { - echo ucfirst($state) . ': ' . $count . '
'; - } - } - ?> -
- -

icon('host')?> Host Actions

- - - - render('multi/components/summary.phtml'); ?> - render('multi/components/comments.phtml'); ?> - render('multi/components/downtimes.phtml'); ?> - -
- - render('multi/components/flags.phtml') ?> - -
- - - - diff --git a/modules/monitoring/application/views/scripts/multi/service.phtml b/modules/monitoring/application/views/scripts/multi/service.phtml deleted file mode 100644 index dc2e9f19e..000000000 --- a/modules/monitoring/application/views/scripts/multi/service.phtml +++ /dev/null @@ -1,61 +0,0 @@ -is_service = true; -$this->hostquery = implode($this->hostnames, ','); -$this->servicequery = implode($this->servicenames, ','); -$this->target = array( - 'host' => $this->hostquery, - 'service' => $this->servicequery -); -?> - -
-tabs ?> -
- -
- - - -

Summary for services

- - - - - - - - - - - - -
Services Hosts
service_pie->render() ?> $count) { - if ($count > 0) { - echo ucfirst($state) . ': ' . $count . '
'; - } - } - - ?>
host_pie->render() ?> $count) { - if ($count > 0) { - echo ucfirst($state) . ': ' . $count . '
'; - } - } - ?>
- -

icon('conf')?> Service Actions

- - - - render('multi/components/objectlist.phtml') ?> - render('multi/components/summary.phtml') ?> - render('multi/components/comments.phtml') ?> - render('multi/components/downtimes.phtml') ?> - -
- - render('multi/components/flags.phtml') ?> - -
diff --git a/modules/monitoring/application/views/scripts/services/show.phtml b/modules/monitoring/application/views/scripts/services/show.phtml index af05979fb..65049b792 100644 --- a/modules/monitoring/application/views/scripts/services/show.phtml +++ b/modules/monitoring/application/views/scripts/services/show.phtml @@ -2,13 +2,14 @@ tabs ?>
- + + translate('No services matching the filter') ?>
- translate('Services (%u)'), array_sum(array_values($serviceStates))) ?> + translatePlural('Service (%u)', 'Services (%u)', $serviceCount), $serviceCount) ?>
serviceStatesPieChart ?> @@ -22,7 +23,8 @@
- translate('Hosts (%u)'), array_sum(array_values($hostStates))) ?> + + translatePlural('Host (%u)', 'Hosts (%u)', $hostCount), $hostCount) ?>
hostStatesPieChart ?> @@ -59,15 +61,23 @@
+ +

+ translatePlural( '%u Unhandled Service Problem', '%u Unhandled Service Problems', - count($unhandledObjects) + $unhandledCount ), - count($unhandledObjects) + $unhandledCount ) ?>

@@ -88,13 +98,14 @@

+ translatePlural( '%u Acknowledged Service Problem', '%u Acknowledged Service Problems', - count($acknowledgedObjects) + $acknowledgedCount ), - count($acknowledgedObjects) + $acknowledgedCount ) ?>

@@ -104,20 +115,36 @@

+ icon('plug') ?> - translate(sprintf('%u services are in downtime', count($objectsInDowntime))) ?> + translatePlural( + '%u service is in downtime', + '%u services are in downtime', + $inDowntimeCount + ), + $inDowntimeCount + ) ?>

- getComments())): ?> + getComments()) ?> +

icon('comment') ?> - translate(sprintf('%u comments', count($objects->getComments()))) ?> + translatePlural( + '%u comment', + '%u comments', + $havingCommentsCount + ), + $havingCommentsCount + ) ?>

diff --git a/modules/monitoring/application/views/scripts/show/components/command.phtml b/modules/monitoring/application/views/scripts/show/components/command.phtml index 715240679..a13ed1bee 100644 --- a/modules/monitoring/application/views/scripts/show/components/command.phtml +++ b/modules/monitoring/application/views/scripts/show/components/command.phtml @@ -5,7 +5,21 @@ $command = array_shift($parts); ?> translate('Command') ?> - escape($command) ?> + + escape($command) ?> + passive_checks_enabled): ?> + getType() === $object::TYPE_HOST): ?> + icon('reply'); ?> translate('Process check result'); ?> + + icon('reply'); ?> translate('Process check result'); ?> + + getType() === $object::TYPE_SERVICE ?> +getType() === $object::TYPE_SERVICE; + +?> compact): ?> - + - +
> - translate($this->util()->getHostStateName($object->host_state)) ?>
+ host_state, true)); ?>
prefixedTimeSince($object->host_last_state_change, true) ?>
escape($object->host_name) ?>
- translate($this->util()->getServiceStateName($object->service_state)) ?>
+ service_state, true)); ?>
prefixedTimeSince($object->service_last_state_change, true) ?>
translate('Service') ?>: escape($object->service_description) ?> diff --git a/modules/monitoring/application/views/scripts/show/components/hostgroups.phtml b/modules/monitoring/application/views/scripts/show/components/hostgroups.phtml index 40db3e5c4..165df627a 100644 --- a/modules/monitoring/application/views/scripts/show/components/hostgroups.phtml +++ b/modules/monitoring/application/views/scripts/show/components/hostgroups.phtml @@ -4,7 +4,7 @@ if (empty($object->hostgroups)) return; $list = array(); foreach ($object->hostgroups as $name => $alias) { - $list[] = $this->qlink($alias, 'monitoring/list/services', array( + $list[] = $this->qlink($alias, 'monitoring/list/hosts', array( 'hostgroup' => $name )); } diff --git a/modules/monitoring/application/views/scripts/show/history.phtml b/modules/monitoring/application/views/scripts/show/history.phtml index dfc1cbf0e..5b922d4a0 100644 --- a/modules/monitoring/application/views/scripts/show/history.phtml +++ b/modules/monitoring/application/views/scripts/show/history.phtml @@ -1,3 +1,10 @@ + +
render('show/components/header.phtml'); ?>

translate('This Object\'s Event History'); ?>

@@ -13,6 +20,7 @@ getType() === 'host'; function contactsLink($match, $view) { $links = array(); foreach (preg_split('/,\s/', $match[1]) as $contact) { @@ -32,11 +40,7 @@ function contactsLink($match, $view) { case 'notify': $icon = 'notification'; $title = $this->translate('Notification'); - $stateClass = ( - $isService - ? strtolower($this->util()->getServiceStateName($event->state)) - : strtolower($this->util()->getHostStateName($event->state)) - ); + $stateClass = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state); $msg = preg_replace_callback( '/^\[([^\]]+)\]/', @@ -86,23 +90,23 @@ function contactsLink($match, $view) { break; case 'hard_state': $msg = '[ ' . $event->attempt . '/' . $event->max_attempts . ' ] ' . $this->escape($event->output); - $stateClass = ( - $isService - ? strtolower($this->util()->getServiceStateName($event->state)) - : strtolower($this->util()->getHostStateName($event->state)) - ); + $stateClass = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state); $icon = 'attention-alt'; - $title = strtoupper($stateClass); // TODO: Should be translatable! + $title = strtoupper( + $isService + ? Service::getStateText($event->state) + : Host::getStateText($event->state) + ); break; case 'soft_state': $icon = 'spinner'; $msg = '[ ' . $event->attempt . '/' . $event->max_attempts . ' ] ' . $this->escape($event->output); - $stateClass = ( + $stateClass = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state); + $title = strtoupper( $isService - ? strtolower($this->util()->getServiceStateName($event->state)) - : strtolower($this->util()->getHostStateName($event->state)) + ? Service::getStateText($event->state) + : Host::getStateText($event->state) ); - $title = strtoupper($stateClass); // TODO: Should be translatable! break; case 'dt_start': $icon = 'downtime_start'; @@ -132,7 +136,13 @@ $output = $this->tickets ? preg_replace_callback( ?> - escape($event->service_description) . ' ' . $this->translate('on') . ' ' . $this->escape($event->host_name); ?> + qlink( + $this->escape($event->service_description), + 'monitoring/show/service', + array( + 'host' => $event->host_name, + 'service' => $event->service_description) + ) : $this->escape($event->service_description); ?> translate('on') . ' ' . $this->escape($event->host_name); ?> escape($event->host_name); ?> diff --git a/modules/monitoring/configuration.php b/modules/monitoring/configuration.php index d61e32858..b1cdee2de 100644 --- a/modules/monitoring/configuration.php +++ b/modules/monitoring/configuration.php @@ -2,7 +2,7 @@ // {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}} -/** @var $this \Icinga\Application\Modules\Module */ +/** @type $this \Icinga\Application\Modules\Module */ $this->providePermission( 'monitoring/command/*', diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php index e390aa114..28b06dc80 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php @@ -518,12 +518,14 @@ class StatusQuery extends IdoQuery protected function joinServiceproblemsummary() { $sub = new Zend_Db_Expr('(SELECT' - . ' SUM(CASE WHEN (ss.problem_has_been_acknowledged + ss.scheduled_downtime_depth) > 0 THEN 0 ELSE 1 END) AS unhandled_services_count,' - . ' SUM(CASE WHEN (ss.problem_has_been_acknowledged + ss.scheduled_downtime_depth) > 0 THEN 1 ELSE 0 END) AS handled_services_count,' + . ' SUM(CASE WHEN (ss.problem_has_been_acknowledged + ss.scheduled_downtime_depth + COALESCE(hs.current_state, 0)) > 0 THEN 0 ELSE 1 END) AS unhandled_services_count,' + . ' SUM(CASE WHEN (ss.problem_has_been_acknowledged + ss.scheduled_downtime_depth + COALESCE(hs.current_state, 0)) > 0 THEN 1 ELSE 0 END) AS handled_services_count,' . ' s.host_object_id FROM icinga_servicestatus ss' . ' JOIN icinga_services s' . ' ON s.service_object_id = ss.service_object_id' . ' AND ss.current_state > 0' + . ' JOIN icinga_hoststatus hs' + . ' ON hs.host_object_id = s.host_object_id' . ' GROUP BY s.host_object_id)'); $this->select->joinLeft( array('sps' => $sub), diff --git a/modules/monitoring/library/Monitoring/Command/Object/ProcessCheckResultCommand.php b/modules/monitoring/library/Monitoring/Command/Object/ProcessCheckResultCommand.php index 9866aeb52..8e3155de5 100644 --- a/modules/monitoring/library/Monitoring/Command/Object/ProcessCheckResultCommand.php +++ b/modules/monitoring/library/Monitoring/Command/Object/ProcessCheckResultCommand.php @@ -34,7 +34,7 @@ class ProcessCheckResultCommand extends ObjectCommand /** * Host unreachable */ - const HOST_UNREACHABLE = 2; + const HOST_UNREACHABLE = 2; // TODO: Icinga 2.x does not support submitting results with this state, yet /** * Service ok diff --git a/modules/monitoring/library/Monitoring/Command/Renderer/IcingaCommandFileCommandRenderer.php b/modules/monitoring/library/Monitoring/Command/Renderer/IcingaCommandFileCommandRenderer.php index d2dca183c..651383255 100644 --- a/modules/monitoring/library/Monitoring/Command/Renderer/IcingaCommandFileCommandRenderer.php +++ b/modules/monitoring/library/Monitoring/Command/Renderer/IcingaCommandFileCommandRenderer.php @@ -30,7 +30,7 @@ class IcingaCommandFileCommandRenderer implements IcingaCommandRendererInterface * * @return string */ - public function escape($commandString) + protected function escape($commandString) { return str_replace(array("\r", "\n"), array('\r', '\n'), $commandString); } @@ -52,7 +52,7 @@ class IcingaCommandFileCommandRenderer implements IcingaCommandRendererInterface if ($now === null) { $now = time(); } - return sprintf('[%u] %s', $now, $this->$renderMethod($command)); + return sprintf('[%u] %s', $now, $this->escape($this->$renderMethod($command))); } public function renderAddComment(AddCommentCommand $command) @@ -126,7 +126,7 @@ class IcingaCommandFileCommandRenderer implements IcingaCommandRendererInterface } else { /** @var \Icinga\Module\Monitoring\Object\Service $object */ $commandString = sprintf( - 'PROCESS_SVC_CHECK_RESULT;%s;%s', + 'PROCESS_SERVICE_CHECK_RESULT;%s;%s', $object->getHost()->getName(), $object->getName() ); diff --git a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php index 4be004d99..2d9f1f30c 100644 --- a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php +++ b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php @@ -421,7 +421,7 @@ abstract class MonitoredObject if ($this->type === self::TYPE_SERVICE) { $eventHistory->where('service_description', $this->service_description); } - $this->eventhistory = $eventHistory->getQuery(); + $this->eventhistory = $eventHistory; return $this; } diff --git a/modules/monitoring/library/Monitoring/Plugin/Perfdata.php b/modules/monitoring/library/Monitoring/Plugin/Perfdata.php index 6af3cde17..7da4559fd 100644 --- a/modules/monitoring/library/Monitoring/Plugin/Perfdata.php +++ b/modules/monitoring/library/Monitoring/Plugin/Perfdata.php @@ -5,9 +5,15 @@ namespace Icinga\Module\Monitoring\Plugin; use InvalidArgumentException; +use Icinga\Exception\ProgrammingError; +use Icinga\Web\Widget\Chart\InlinePie; +use Zend_Controller_Front; class Perfdata { + const PERFDATA_DEFAULT = 'green'; + const PERFDATA_RED = 'red'; + /** * The performance data value being parsed * @@ -159,6 +165,16 @@ class Perfdata return $this->unit === 'c'; } + /** + * Returns whether it is possible to display a visual representation + * + * @return bool True when the perfdata is visualizable + */ + public function isVisualizable() + { + return isset($this->minValue) && isset($this->maxValue) && isset($this->value); + } + /** * Return this perfomance data's label */ @@ -316,4 +332,50 @@ class Perfdata } } } + + protected function calculatePieChartData( $color) + { + $rawValue = $this->getValue(); + $minValue = $this->getMinimumValue() !== null ? $this->getMinimumValue() : 0; + $maxValue = $this->getMaximumValue(); + $usedValue = ($rawValue - $minValue); + $unusedValue = ($maxValue - $minValue) - $usedValue; + + $gray = $unusedValue; + $green = $orange = $red = 0; + + switch ($color) { + case self::PERFDATA_DEFAULT: + $green = $usedValue; + break; + + case self::PERFDATA_RED: + $red = $usedValue; + break; + + case self::PERFDATA_ORANGE: + $orange = $usedValue; + break; + } + // TODO(#6122): Add proper treshold parsing. + + return array($green, $orange, $red, $gray); + } + + + public function asInlinePie($color) + { + if (! $this->isVisualizable()) { + throw new ProgrammingError('Cannot calculate piechart data for unvisualizable perfdata entry.'); + } + + $data = $this->calculatePieChartData($color); + $pieChart = new InlinePie($data, $this->getLabel() . ' ' . number_format($this->getPercentage(), 2) . '%'); + $pieChart->setSparklineClass('sparkline-perfdata'); + + if (Zend_Controller_Front::getInstance()->getRequest()->isXmlHttpRequest()) { + $pieChart->disableNoScript(); + } + return $pieChart; + } } diff --git a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php index 7ee73d575..94dbe3f10 100644 --- a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php +++ b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php @@ -223,8 +223,6 @@ abstract class MonitoredObjectController extends Controller ) ); } - $tabs - ->extend(new OutputFormat()) - ->extend(new DashboardAction()); + $tabs->extend(new DashboardAction()); } } diff --git a/modules/monitoring/library/Monitoring/Web/Hook/TopBar.php b/modules/monitoring/library/Monitoring/Web/Hook/TopBar.php deleted file mode 100644 index 082a03c5b..000000000 --- a/modules/monitoring/library/Monitoring/Web/Hook/TopBar.php +++ /dev/null @@ -1,61 +0,0 @@ -getQuery()->fetchRow(); - - $serviceSummary = StatusSummaryView::fromRequest( - $request, - array( - 'services_ok', - 'services_critical_handled', - 'services_critical_unhandled', - 'services_warning_handled', - 'services_warning_unhandled', - 'services_unknown_handled', - 'services_unknown_unhandled', - 'services_pending' - ) - )->getQuery()->fetchRow(); - - return $this->getView()->partial( - 'layout/topbar.phtml', - 'monitoring', - array( - 'hostSummary' => $hostSummary, - 'serviceSummary' => $serviceSummary - ) - ); - } -} diff --git a/modules/monitoring/run.php b/modules/monitoring/run.php deleted file mode 100644 index 8f4ee1b67..000000000 --- a/modules/monitoring/run.php +++ /dev/null @@ -1,8 +0,0 @@ -registerHook( - 'TopBar', - 'Icinga\\Module\\Monitoring\\Web\\Hook\\TopBar' -); diff --git a/modules/monitoring/test/php/regression/Bug6088Test.php b/modules/monitoring/test/php/regression/Bug6088Test.php new file mode 100644 index 000000000..0a4f60a58 --- /dev/null +++ b/modules/monitoring/test/php/regression/Bug6088Test.php @@ -0,0 +1,63 @@ +getBug() . ';' . $command->getParameterWithCarriageReturnAndLineFeed(); + } +} + + +/** + * Class Bug6088 + * + * Multi-line comments don't work + * + * @see https://dev.icinga.org/issues/6088 + */ +class Bug6088Test extends BaseTestCase +{ + public function testWhetherCommandParametersWithMultipleLinesAreProperlyEscaped() + { + $command = new Bug6088Command(); + $renderer = new Bug6088CommandFileCommandRenderer(); + $commandString = $renderer->render($command); + + $this->assertEquals( + 'SOLVE_BUG;6088;foo\r\nbar', + substr($commandString, strpos($commandString, ' ') + 1), + 'Command parameters with multiple lines are not properly escaped' + ); + } +} diff --git a/modules/setup/application/forms/AuthBackendPage.php b/modules/setup/application/forms/AuthBackendPage.php index fac2a7bbd..bd820d352 100644 --- a/modules/setup/application/forms/AuthBackendPage.php +++ b/modules/setup/application/forms/AuthBackendPage.php @@ -112,7 +112,7 @@ class AuthBackendPage extends Form } $this->addElements($backendForm->getElements()); - $this->getElement('name')->setValue('icingaweb'); + $this->getElement('name')->setValue('icingaweb2'); } /** diff --git a/modules/setup/application/views/scripts/form/setup-welcome.phtml b/modules/setup/application/views/scripts/form/setup-welcome.phtml index 6c8228541..9aad09dbc 100644 --- a/modules/setup/application/views/scripts/form/setup-welcome.phtml +++ b/modules/setup/application/views/scripts/form/setup-welcome.phtml @@ -51,9 +51,7 @@ $cliPath = realpath(Icinga::app()->getApplicationDir() . '/../bin/icingacli');

- su && mkdir -m 2770 ; - head -c 12 /dev/urandom | base64 | tee ; - chmod 0660 ; + su -c "mkdir -m 2770 ; head -c 12 /dev/urandom | base64 | tee ; chmod 0660 ;";

sprintf( - mt('setup', 'Cannot validate token, file "%s" must only be accessible by the webserver\'s user.'), - $tokenPath - ), 'TOKEN_INVALID' => mt('setup', 'Invalid token supplied.') ); } @@ -56,12 +52,6 @@ class TokenValidator extends Zend_Validate_Abstract */ public function isValid($value, $context = null) { - $tokenStats = @stat($this->tokenPath); - if (($tokenStats['mode'] & 4) === 4) { - $this->_error('TOKEN_FILE_PUBLIC'); - return false; - } - try { $file = new File($this->tokenPath); $expectedToken = trim($file->fgets()); diff --git a/modules/setup/library/Setup/WebWizard.php b/modules/setup/library/Setup/WebWizard.php index 72cd4f286..102c2c6a0 100644 --- a/modules/setup/library/Setup/WebWizard.php +++ b/modules/setup/library/Setup/WebWizard.php @@ -9,6 +9,7 @@ use Icinga\Web\Form; use Icinga\Web\Wizard; use Icinga\Web\Request; use Icinga\Application\Config; +use Icinga\Application\Icinga; use Icinga\Application\Platform; use Icinga\Module\Setup\Forms\ModulePage; use Icinga\Module\Setup\Forms\WelcomePage; @@ -343,7 +344,7 @@ class WebWizard extends Wizard implements SetupWizard ); } - $configDir = $this->getConfigDir(); + $configDir = Icinga::app()->getConfigDir(); $setup->addStep( new MakeDirStep( array( @@ -351,7 +352,7 @@ class WebWizard extends Wizard implements SetupWizard $configDir . '/preferences', $configDir . '/enabledModules' ), - 0775 + 2770 ) ); @@ -461,8 +462,8 @@ class WebWizard extends Wizard implements SetupWizard mt('setup', 'PHP Module: GD'), mt( 'setup', - 'In case you want icons and graphs being exported to PDF' - . ' as well, you\'ll need the GD extension for PHP.' + 'In case you want views being exported to PDF,' + . ' you\'ll need the GD extension for PHP.' ), Platform::extensionLoaded('gd'), Platform::extensionLoaded('gd') ? mt('setup', 'The PHP module GD is available') : ( @@ -470,6 +471,19 @@ class WebWizard extends Wizard implements SetupWizard ) ); + $requirements->addOptional( + mt('setup', 'PHP Module: Imagick'), + mt( + 'setup', + 'In case you want graphs being exported to PDF as well' + . ', you\'ll need the ImageMagick extension for PHP.' + ), + Platform::extensionLoaded('imagick'), + Platform::extensionLoaded('imagick') ? mt('setup', 'The PHP module Imagick is available') : ( + mt('setup', 'The PHP module Imagick is missing') + ) + ); + $requirements->addOptional( mt('setup', 'PHP Module: PDO-MySQL'), mt( @@ -515,12 +529,12 @@ class WebWizard extends Wizard implements SetupWizard ) ); - $configDir = $this->getConfigDir(); + $configDir = Icinga::app()->getConfigDir(); $requirements->addMandatory( mt('setup', 'Writable Config Directory'), mt( 'setup', - 'The Icinga Web 2 configuration directory defaults to "/etc/icingaweb", if' . + 'The Icinga Web 2 configuration directory defaults to "/etc/icingaweb2", if' . ' not explicitly set in the environment variable "ICINGAWEB_CONFIGDIR".' ), is_writable($configDir), @@ -538,21 +552,4 @@ class WebWizard extends Wizard implements SetupWizard return $requirements; } - - /** - * Return the configuration directory of Icinga Web 2 - * - * @return string - */ - protected function getConfigDir() - { - if (array_key_exists('ICINGAWEB_CONFIGDIR', $_SERVER)) { - $configDir = $_SERVER['ICINGAWEB_CONFIGDIR']; - } else { - $configDir = '/etc/icingaweb'; - } - - $canonical = realpath($configDir); - return $canonical ? $canonical : $configDir; - } } diff --git a/modules/translation/library/Translation/Util/GettextTranslationHelper.php b/modules/translation/library/Translation/Util/GettextTranslationHelper.php index 0d5a950e1..5702def85 100644 --- a/modules/translation/library/Translation/Util/GettextTranslationHelper.php +++ b/modules/translation/library/Translation/Util/GettextTranslationHelper.php @@ -101,7 +101,7 @@ class GettextTranslationHelper */ public function __construct(ApplicationBootstrap $bootstrap, $locale) { - $this->moduleMgr = $bootstrap->getModuleManager()->loadCoreModules()->loadEnabledModules(); + $this->moduleMgr = $bootstrap->getModuleManager()->loadEnabledModules(); $this->appDir = $bootstrap->getApplicationDir(); $this->locale = $locale; } diff --git a/packages/files/apache/icingaweb.conf b/packages/files/apache/icingaweb2.conf similarity index 91% rename from packages/files/apache/icingaweb.conf rename to packages/files/apache/icingaweb2.conf index 2c52b73e3..6bf0b7a66 100644 --- a/packages/files/apache/icingaweb.conf +++ b/packages/files/apache/icingaweb2.conf @@ -1,4 +1,4 @@ -Alias /icingaweb "/usr/share/icingaweb2/public" +Alias /icingaweb2 "/usr/share/icingaweb2/public" Options SymLinksIfOwnerMatch @@ -23,7 +23,7 @@ Alias /icingaweb "/usr/share/icingaweb2/public" RewriteEngine on - RewriteBase /icingaweb/ + RewriteBase /icingaweb2/ RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d diff --git a/packages/files/bin/icingacli b/packages/files/bin/icingacli index 10b4857aa..5b41e4e8c 100755 --- a/packages/files/bin/icingacli +++ b/packages/files/bin/icingacli @@ -3,4 +3,4 @@ require_once '/usr/share/php/Icinga/Application/Cli.php'; -Icinga\Application\Cli::start('/usr/share/icingaweb')->dispatch(); +Icinga\Application\Cli::start('/usr/share/icingaweb2')->dispatch(); diff --git a/packages/files/modules/doc/config.ini b/packages/files/modules/doc/config.ini new file mode 100644 index 000000000..80df20784 --- /dev/null +++ b/packages/files/modules/doc/config.ini @@ -0,0 +1,3 @@ +[documentation] +icingaweb2 = /usr/share/doc/icingaweb2/markdown +modules = /usr/share/doc/icingaweb2/modules/{module}/markdown diff --git a/public/css/icinga/monitoring-colors.less b/public/css/icinga/monitoring-colors.less index 52154c24e..1e657101f 100644 --- a/public/css/icinga/monitoring-colors.less +++ b/public/css/icinga/monitoring-colors.less @@ -65,11 +65,12 @@ table.action td a:hover { text-decoration: underline; } -table.action div.inlinepie { +table.action span.sparkline, table.action img.inlinepie { margin: 0.5em 0.25em 0.5em 0.25em; + float:right; } -.dashboard table.action div.inlinepie { +.dashboard table.action span.sparkline, .dashboard table.action img.inlinepie { margin: 0em 0.25em 0em 0.25em; } diff --git a/public/css/icinga/widgets.less b/public/css/icinga/widgets.less index 93625b0dc..e2e37d7ab 100644 --- a/public/css/icinga/widgets.less +++ b/public/css/icinga/widgets.less @@ -285,3 +285,10 @@ li li .badge { .widgetFilter li.active { background-color: #eee; } + +.sparkline { + width: 12px; + height: 12px; + position: relative; + top: 4px; +} \ No newline at end of file diff --git a/public/css/pdf/pdfprint.less b/public/css/pdf/pdfprint.less index 874a5e518..117bef546 100644 --- a/public/css/pdf/pdfprint.less +++ b/public/css/pdf/pdfprint.less @@ -1,10 +1,15 @@ // {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}} -.controls form, .controls .pagination, .controls > .tabs, .dontprint, .inlinepie { +.controls form, .controls .pagination, .controls .widgetLimiter, .controls > .tabs, .dontprint { display: none !important; } +table.action img.inlinepie { + width: 50%; + height: 50%; +} + @page { margin: 2cm; } diff --git a/public/js/icinga/behavior/navigation.js b/public/js/icinga/behavior/navigation.js index fde043c01..53fc5c8af 100644 --- a/public/js/icinga/behavior/navigation.js +++ b/public/js/icinga/behavior/navigation.js @@ -32,6 +32,15 @@ if ($outerMenu.size()) { $outerMenu.addClass('active'); } + + /* + Recreate the html content of the menu item to force the browser to update the layout, or else + the link would only be visible as active after another click or page reload in Gecko and WebKit. + + fixes #7897 + */ + $selectedMenu.html($selectedMenu.html()); + } else { // store menu state var $menus = $('#menu li.active', el); diff --git a/public/js/icinga/behavior/sparkline.js b/public/js/icinga/behavior/sparkline.js index 33cc0d34b..e0d0fb0c7 100644 --- a/public/js/icinga/behavior/sparkline.js +++ b/public/js/icinga/behavior/sparkline.js @@ -18,34 +18,33 @@ $('span.sparkline', el).each(function(i, element) { // read custom options - var $spark = $(element); - var labels = $spark.attr('labels').split('|'); - var formatted = $spark.attr('formatted').split('|'); - var tooltipChartTitle = $spark.attr('sparkTooltipChartTitle') || ''; - var format = $spark.attr('tooltipformat'); - var hideEmpty = $spark.attr('hideEmptyLabel') === 'true'; - $spark.sparkline( - 'html', - { + var $spark = $(element); + var title = $spark.attr('title'); + + if ($spark.attr('labels')) { + $spark.removeAttr('original-title'); + } + + var options; + if ($spark.hasClass('sparkline-perfdata')) { + options = { enableTagOptions: true, - tooltipFormatter: function (sparkline, options, fields) { - var out = format; - if (hideEmpty && fields.offset === 3) { - return ''; - } - var replace = { - title: tooltipChartTitle, - label: labels[fields.offset] ? labels[fields.offset] : fields.offset, - formatted: formatted[fields.offset] ? formatted[fields.offset] : '', - value: fields.value, - percent: Math.round(fields.percent * 100) / 100 - }; - $.each(replace, function(key, value) { - out = out.replace('{{' + key + '}}', value); - }); - return out; - } - }); + width: 12, + height: 12, + title: title, + disableTooltips: true + }; + $spark.sparkline('html', options); + } else if ($spark.hasClass('sparkline-multi')) { + options = { + width: 100, + height: 100, + title: title, + enableTagOptions: true + }; + $spark.sparkline('html', options); + } + }); };