From 385402972a3f4566393faaf28bf09cbcc5191ab0 Mon Sep 17 00:00:00 2001 From: varac Date: Tue, 3 May 2016 21:18:33 +0200 Subject: use inventory_only_on_changes to always run inventory and nagios reload By default ($inventory_only_on_changes set to `true`) these two execs are called only when config files changes: - Exec['check_mk-refresh'] (which inventorizes checks by calling `check_mk -II`) - Exec['check_mk-reload'] (which generates the nagios config and reloads nagios by calling `check_mk -O`) By setting this parameter to `false` these execs will be called on each puppetrun. --- README.md | 6 ++++++ manifests/config.pp | 15 ++++++++------- manifests/init.pp | 36 +++++++++++++++++++----------------- 3 files changed, 33 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index a8736f2..81e1bc8 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,12 @@ created making the URL http://hostname/acme/check_mk/ running as the 'acme' user *use_ssh*: Configures ssh to agents that use the same parameter. Default: false. +*inventory_only_on_changes*: By default (parameter set to `true`) these two execs are called + only when config files changes: + - Exec['check_mk-refresh'] (which runs a check inventory by calling `check_mk -II`) + - Exec['check_mk-reload'] (which generates the nagios config and reloads nagios by calling `check_mk -O`) + By setting this parameter to `false` these execs will be called on each puppetrun. + ### Notes * A user and group with the same value as the site parameter is created. By default this is 'monitoring'. diff --git a/manifests/config.pp b/manifests/config.pp index a9f99d8..522be19 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -1,11 +1,12 @@ # Deploy check_mk config class check_mk::config ( $site, - $host_groups = undef, - $etc_dir = "/omd/sites/${site}/etc", - $nagios_subdir = 'nagios', - $bin_dir = "/omd/sites/${site}/bin", - $use_storedconfigs = true + $host_groups = undef, + $etc_dir = "/omd/sites/${site}/etc", + $nagios_subdir = 'nagios', + $bin_dir = "/omd/sites/${site}/bin", + $use_storedconfigs = true, + $inventory_only_on_changes = true ) { file { # for local check_mk checks @@ -93,12 +94,12 @@ class check_mk::config ( # re-read config if it changes exec { 'check_mk-refresh': command => "/bin/su -l -c '${bin_dir}/check_mk -II' ${site}", - refreshonly => true, + refreshonly => $inventory_only_on_changes, notify => Exec['check_mk-reload'], } exec { 'check_mk-reload': command => "/bin/su -l -c '${bin_dir}/check_mk -O' ${site}", - refreshonly => true, + refreshonly => $inventory_only_on_changes, creates => '/etc/nagios3/conf.d/check_mk/check_mk_objects.cfg' } # re-read inventory at least daily diff --git a/manifests/init.pp b/manifests/init.pp index 297c0b8..4aab837 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,18 +1,19 @@ # configure check_mk server class check_mk ( - $filestore = undef, - $host_groups = undef, - $package = 'omd-0.56', - $site = 'monitoring', - $workspace = '/root/check_mk', - $omd_service_name = 'omd', - $http_service_name = 'httpd', - $xinitd_service_name = 'xinetd', - $omdadmin_htpasswd = undef, - $use_ssh = false, - $shelluser = 'monitoring', - $shellgroup = 'monitoring', - $use_storedconfigs = true ) { + $filestore = undef, + $host_groups = undef, + $package = 'omd-0.56', + $site = 'monitoring', + $workspace = '/root/check_mk', + $omd_service_name = 'omd', + $http_service_name = 'httpd', + $xinitd_service_name = 'xinetd', + $omdadmin_htpasswd = undef, + $use_ssh = false, + $shelluser = 'monitoring', + $shellgroup = 'monitoring', + $use_storedconfigs = true, + $inventory_only_on_changes = true) { class { 'check_mk::install': filestore => $filestore, @@ -21,10 +22,11 @@ class check_mk ( workspace => $workspace, } class { 'check_mk::config': - host_groups => $host_groups, - site => $site, - use_storedconfigs => $use_storedconfigs, - require => Class['check_mk::install'], + host_groups => $host_groups, + site => $site, + use_storedconfigs => $use_storedconfigs, + inventory_only_on_changes => $inventory_only_on_changes, + require => Class['check_mk::install'], } class { 'check_mk::service': require => Class['check_mk::config'], -- cgit v1.2.3