From 6ce47f297b5fe23937f2b58d6bf1ccf232670851 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 13 Aug 2013 10:17:44 +0200 Subject: [PATCH 1/5] Vagrant: Install Perl module Monitoring::Generator::TestConfig refs #4506 --- .vagrant-puppet/manifests/default.pp | 5 +++ .../modules/cpan/manifests/init.pp | 43 +++++++++++++++++++ .../modules/cpan/templates/MyConfig.pm.erb | 5 +++ 3 files changed, 53 insertions(+) create mode 100644 .vagrant-puppet/modules/cpan/manifests/init.pp create mode 100644 .vagrant-puppet/modules/cpan/templates/MyConfig.pm.erb diff --git a/.vagrant-puppet/manifests/default.pp b/.vagrant-puppet/manifests/default.pp index ec1713524..545bd0d98 100644 --- a/.vagrant-puppet/manifests/default.pp +++ b/.vagrant-puppet/manifests/default.pp @@ -384,3 +384,8 @@ exec { 'install php-ZendFramework-Db-Adapter-Pdo-Pgsql': unless => 'rpm -qa | grep php-ZendFramework-Db-Adapter-Pdo-Pgsql', require => Exec['install ZendFramework'] } + +cpan { 'Monitoring::Generator::TestConfig': + creates => '/usr/local/share/perl5/Monitoring/Generator/TestConfig.pm', + timeout => 600 +} diff --git a/.vagrant-puppet/modules/cpan/manifests/init.pp b/.vagrant-puppet/modules/cpan/manifests/init.pp new file mode 100644 index 000000000..5aa4e94a8 --- /dev/null +++ b/.vagrant-puppet/modules/cpan/manifests/init.pp @@ -0,0 +1,43 @@ +# Define: cpan +# +# Download and install Perl modules from the Perl Archive Network, the gateway to all things Perl. +# 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: +# +# 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/CPAN/MyConfig.pm': + content => template('cpan/MyConfig.pm.erb'), + require => Package['perl-CPAN'] + } + + exec { "cpan-${name}": + command => "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..057562e5a --- /dev/null +++ b/.vagrant-puppet/modules/cpan/templates/MyConfig.pm.erb @@ -0,0 +1,5 @@ +$CPAN::Config = { + 'prerequisites_policy' => q[follow] +}; +1; +__END__ From 720db8bf77bdf98e6f97c71e38972da3de9cd086 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 13 Aug 2013 11:22:33 +0200 Subject: [PATCH 2/5] Vagrant: Fix installation of Perl module Monitoring::Generator::TestConfig refs #4506 --- .../modules/cpan/manifests/init.pp | 2 +- .../modules/cpan/templates/MyConfig.pm.erb | 65 ++++++++++++++++++- 2 files changed, 65 insertions(+), 2 deletions(-) diff --git a/.vagrant-puppet/modules/cpan/manifests/init.pp b/.vagrant-puppet/modules/cpan/manifests/init.pp index 5aa4e94a8..258ea63ca 100644 --- a/.vagrant-puppet/modules/cpan/manifests/init.pp +++ b/.vagrant-puppet/modules/cpan/manifests/init.pp @@ -35,7 +35,7 @@ define cpan( } exec { "cpan-${name}": - command => "perl -MCPAN -e 'install ${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 index 057562e5a..da410a188 100644 --- a/.vagrant-puppet/modules/cpan/templates/MyConfig.pm.erb +++ b/.vagrant-puppet/modules/cpan/templates/MyConfig.pm.erb @@ -1,5 +1,68 @@ $CPAN::Config = { - 'prerequisites_policy' => q[follow] + '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__ From 0a5db0fb3a25c50ec4778d7e6fed984f39577b4c Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 13 Aug 2013 11:23:42 +0200 Subject: [PATCH 3/5] Vagrant: Install test config to both the MySQL and PostgreSQL Icinga instance refs #4506 --- .vagrant-puppet/manifests/default.pp | 50 ++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/.vagrant-puppet/manifests/default.pp b/.vagrant-puppet/manifests/default.pp index 545bd0d98..b7f1e5214 100644 --- a/.vagrant-puppet/manifests/default.pp +++ b/.vagrant-puppet/manifests/default.pp @@ -385,7 +385,57 @@ exec { 'install 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' +} + +define populate_monitoring_test_config { + file { "/usr/local/icinga-mysql/etc/conf.d/test_config/${name}.cfg": + recurse => true, + 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/']] +} From a2de4a8c22e7bf6e38bf25bd188e9c1d8a190a78 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 13 Aug 2013 13:39:57 +0200 Subject: [PATCH 4/5] Vagrant: Install Icinga plugins from Perl module Monitoring::Generator::TestConfig too refs #4506 --- .vagrant-puppet/manifests/default.pp | 52 ++++++++++++++++++---------- README.md | 13 +++++++ 2 files changed, 46 insertions(+), 19 deletions(-) diff --git a/.vagrant-puppet/manifests/default.pp b/.vagrant-puppet/manifests/default.pp index b7f1e5214..4eaaf99d6 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': @@ -405,7 +405,6 @@ exec { 'create_monitoring_test_config': define populate_monitoring_test_config { file { "/usr/local/icinga-mysql/etc/conf.d/test_config/${name}.cfg": - recurse => true, owner => 'icinga', group => 'icinga', source => "/usr/local/share/misc/monitoring_test_config/etc/conf.d/${name}.cfg", @@ -435,7 +434,22 @@ file { '/usr/local/icinga-pgsql/etc/conf.d/test_config': 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/']] + 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/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. From 63999c80aca88739f73ff243ad027a2746010e9e Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 14 Aug 2013 14:35:37 +0200 Subject: [PATCH 5/5] Vagrant: Fix installation of perl-CPAN refs #4506 --- .vagrant-puppet/manifests/default.pp | 7 ++++--- .../modules/cmmi/manifests/init.pp | 16 +++++++-------- .../modules/cpan/manifests/init.pp | 20 ++++++++++++------- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/.vagrant-puppet/manifests/default.pp b/.vagrant-puppet/manifests/default.pp index 4eaaf99d6..e83d88a75 100644 --- a/.vagrant-puppet/manifests/default.pp +++ b/.vagrant-puppet/manifests/default.pp @@ -400,7 +400,8 @@ 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' + creates => '/usr/local/share/misc/monitoring_test_config', + require => Cpan['Monitoring::Generator::TestConfig'] } define populate_monitoring_test_config { @@ -418,14 +419,14 @@ define populate_monitoring_test_config { } } -file { '/usr/local/icinga-mysql/etc/conf.d/test_config': +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': +file { '/usr/local/icinga-pgsql/etc/conf.d/test_config/': ensure => directory, owner => icinga, group => icinga, 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 index 258ea63ca..9cbdaf8b0 100644 --- a/.vagrant-puppet/modules/cpan/manifests/init.pp +++ b/.vagrant-puppet/modules/cpan/manifests/init.pp @@ -1,7 +1,6 @@ # Define: cpan # -# Download and install Perl modules from the Perl Archive Network, the gateway to all things Perl. -# The canonical location for Perl code and modules. +# 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. @@ -11,12 +10,14 @@ # # Requires: # +# Perl +# # Sample Usage: # -# cpan { 'perl-module': -# creates => '/usr/local/share/perl5/perl-module', -# timeout => 600 -# } +# cpan { 'perl-module': +# creates => '/usr/local/share/perl5/perl-module', +# timeout => 600 +# } # define cpan( $creates, @@ -29,9 +30,14 @@ define 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'] + require => [ Package['perl-CPAN'], + File[[ '/root/.cpan/', '/root/.cpan/CPAN/' ]] ] } exec { "cpan-${name}":