diff --git a/.vagrant-puppet/manifests/default.pp b/.vagrant-puppet/manifests/default.pp index ec1713524..e83d88a75 100644 --- a/.vagrant-puppet/manifests/default.pp +++ b/.vagrant-puppet/manifests/default.pp @@ -28,7 +28,7 @@ $icinga_packages = [ 'gcc', 'glibc', 'glibc-common', 'gd', 'gd-devel', package { $icinga_packages: ensure => installed } php::extension { ['php-mysql', 'php-pgsql', 'php-ldap']: - require => [Class['mysql'], Class['pgsql'], Class['openldap']] + require => [ Class['mysql'], Class['pgsql'], Class['openldap'] ] } group { 'icinga-cmd': @@ -43,7 +43,7 @@ user { 'icinga': user { 'apache': groups => 'icinga-cmd', - require => [Class['apache'], Group['icinga-cmd']] + require => [ Class['apache'], Group['icinga-cmd'] ] } cmmi { 'icinga-mysql': @@ -57,7 +57,7 @@ cmmi { 'icinga-mysql': --with-plugin-dir=/usr/lib64/nagios/plugins/libexec', creates => '/usr/local/icinga-mysql', make => 'make all && make fullinstall install-config', - require => [User['icinga'], Cmmi['icinga-plugins'], Package['apache']], + require => [ User['icinga'], Cmmi['icinga-plugins'], Package['apache'] ], notify => Service['apache'] } @@ -83,7 +83,7 @@ cmmi { 'icinga-pgsql': --with-plugin-dir=/usr/lib64/nagios/plugins/libexec', creates => '/usr/local/icinga-pgsql', make => 'make all && make fullinstall install-config', - require => [User['icinga'], Cmmi['icinga-plugins'], Package['apache']], + require => [ User['icinga'], Cmmi['icinga-plugins'], Package['apache'] ], notify => Service['apache'] } @@ -100,13 +100,13 @@ file { '/etc/init.d/ido2db-pgsql': exec { 'populate-icinga-mysql-db': unless => 'mysql -uicinga -picinga icinga -e "SELECT * FROM icinga_dbversion;" &> /dev/null', command => 'mysql -uicinga -picinga icinga < /usr/local/src/icinga-mysql/icinga-1.9.3/module/idoutils/db/mysql/mysql.sql', - require => [Cmmi['icinga-mysql'], Exec['create-mysql-icinga-db']] + 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-1.9.3/module/idoutils/db/pgsql/pgsql.sql', - require => [Cmmi['icinga-pgsql'], Exec['create-pgsql-icinga-db']] + require => [ Cmmi['icinga-pgsql'], Exec['create-pgsql-icinga-db'] ] } service { 'icinga-mysql': @@ -124,7 +124,7 @@ file { '/usr/local/icinga-mysql/etc/ido2db.cfg': owner => 'icinga', group => 'icinga', require => Cmmi['icinga-mysql'], - notify => [Service['icinga-mysql'], Service['ido2db-mysql']] + notify => [ Service['icinga-mysql'], Service['ido2db-mysql'] ] } file { '/usr/local/icinga-mysql/etc/idomod.cfg': @@ -132,7 +132,7 @@ file { '/usr/local/icinga-mysql/etc/idomod.cfg': owner => 'icinga', group => 'icinga', require => Cmmi['icinga-mysql'], - notify => [Service['icinga-mysql'], Service['ido2db-mysql']] + notify => [ Service['icinga-mysql'], Service['ido2db-mysql'] ] } file { '/usr/local/icinga-mysql/etc/modules/idoutils.cfg': @@ -140,7 +140,7 @@ file { '/usr/local/icinga-mysql/etc/modules/idoutils.cfg': owner => 'icinga', group => 'icinga', require => Cmmi['icinga-mysql'], - notify => [Service['icinga-mysql'], Service['ido2db-mysql']] + notify => [ Service['icinga-mysql'], Service['ido2db-mysql'] ] } service { 'icinga-pgsql': @@ -158,7 +158,7 @@ file { '/usr/local/icinga-pgsql/etc/ido2db.cfg': owner => 'icinga', group => 'icinga', require => Cmmi['icinga-pgsql'], - notify => [Service['icinga-pgsql'], Service['ido2db-pgsql']] + notify => [ Service['icinga-pgsql'], Service['ido2db-pgsql'] ] } file { '/usr/local/icinga-pgsql/etc/idomod.cfg': @@ -166,7 +166,7 @@ file { '/usr/local/icinga-pgsql/etc/idomod.cfg': owner => 'icinga', group => 'icinga', require => Cmmi['icinga-pgsql'], - notify => [Service['icinga-pgsql'], Service['ido2db-pgsql']] + notify => [ Service['icinga-pgsql'], Service['ido2db-pgsql'] ] } file { '/usr/local/icinga-pgsql/etc/modules/idoutils.cfg': @@ -174,7 +174,7 @@ file { '/usr/local/icinga-pgsql/etc/modules/idoutils.cfg': owner => 'icinga', group => 'icinga', require => Cmmi['icinga-pgsql'], - notify => [Service['icinga-pgsql'], Service['ido2db-pgsql']] + notify => [ Service['icinga-pgsql'], Service['ido2db-pgsql'] ] } exec { 'iptables-allow-http': @@ -213,7 +213,7 @@ file { '/usr/local/icinga-mysql/etc/modules/mk-livestatus.cfg': owner => 'icinga', group => 'icinga', require => Cmmi['mk-livestatus'], - notify => [Service['icinga-mysql'], Service['ido2db-mysql']] + notify => [ Service['icinga-mysql'], Service['ido2db-mysql'] ] } file { 'openldap/db.ldif': @@ -239,8 +239,8 @@ exec { 'populate-openldap': 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']] + require => [ Service['slapd'], File['openldap/db.ldif'], + File['openldap/dit.ldif'], File['openldap/users.ldif'] ] } class { 'phantomjs': @@ -384,3 +384,73 @@ exec { 'install php-ZendFramework-Db-Adapter-Pdo-Pgsql': unless => 'rpm -qa | grep php-ZendFramework-Db-Adapter-Pdo-Pgsql', require => Exec['install 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/libexec/${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'] ] +} diff --git a/.vagrant-puppet/modules/cmmi/manifests/init.pp b/.vagrant-puppet/modules/cmmi/manifests/init.pp index c2d7b71f6..e7586a666 100644 --- a/.vagrant-puppet/modules/cmmi/manifests/init.pp +++ b/.vagrant-puppet/modules/cmmi/manifests/init.pp @@ -19,14 +19,14 @@ # # 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 -# } +# 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, diff --git a/.vagrant-puppet/modules/cpan/manifests/init.pp b/.vagrant-puppet/modules/cpan/manifests/init.pp new file mode 100644 index 000000000..9cbdaf8b0 --- /dev/null +++ b/.vagrant-puppet/modules/cpan/manifests/init.pp @@ -0,0 +1,49 @@ +# 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 new file mode 100644 index 000000000..da410a188 --- /dev/null +++ b/.vagrant-puppet/modules/cpan/templates/MyConfig.pm.erb @@ -0,0 +1,68 @@ +$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/README.md b/README.md index 57db19b24..89032e17d 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ After you should be able to browse [localhost:8080/icinga2-web](http://localhost * MySQL server and client software * PostgreSQL server and client software * [Icinga prerequisites](http://docs.icinga.org/latest/en/quickstart-idoutils.html#installpackages) +* OpenLDAP servers and clients **Installed users and groups**: @@ -102,6 +103,18 @@ Connect to the **icinga mysql database** using the following command: Access the **Classic UI** (CGIs) via [localhost:8080/icinga-pgsql](http://localhost:8080/icinga-pgsql). For **logging into** the Icinga classic web interface use user *icingaadmin* with password *icinga*. +#### Monitoring Test Config + +Test config is added to both the MySQL and PostgreSQL Icinga instance utilizing the Perl module +**Monitoring::Generator::TestConfig** to generate test config to **/usr/local/share/misc/monitoring_test_config** +which is then copied to **/etc/conf.d/test_config/**. +Configuration can be adjusted and recreated with **/usr/local/share/misc/monitoring_test_config/recreate.pl**. +**Note** that you have to run + + vagrant provision + +in the host after any modification to the script just mentioned. + #### MK Livestatus MK Livestatus is added to the Icinga installation using a MySQL database.