summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md6
-rw-r--r--manifests/config.pp43
-rw-r--r--manifests/init.pp37
3 files changed, 48 insertions, 38 deletions
diff --git a/README.md b/README.md
index 5030dba..8030581 100644
--- a/README.md
+++ b/README.md
@@ -75,6 +75,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 6736147..fba6836 100644
--- a/manifests/config.pp
+++ b/manifests/config.pp
@@ -1,10 +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
@@ -13,11 +15,10 @@ class check_mk::config (
# package provided and check_mk generated files, defined so the nagios
# module doesn't purge them
+ "${etc_dir}/${nagios_subdir}/conf.d":
+ ensure => directory;
"${etc_dir}/${nagios_subdir}/conf.d/check_mk":
ensure => directory;
- [ "${etc_dir}/${nagios_subdir}/conf.d/check_mk/check_mk_objects.cfg",
- "${etc_dir}/${nagios_subdir}/conf.d/check_mk/check_mk_templates.cfg" ]:
- ensure => present;
}
file_line { 'nagios-add-check_mk-cfg_dir':
ensure => present,
@@ -57,9 +58,9 @@ class check_mk::config (
# local list of hosts is in /omd/sites/${site}/etc/check_mk/all_hosts_static and is appended
concat::fragment { 'all-hosts-static':
- ensure => "${etc_dir}/check_mk/all_hosts_static",
- target => "${etc_dir}/check_mk/main.mk",
- order => 18,
+ ensure => "${etc_dir}/check_mk/all_hosts_static",
+ target => "${etc_dir}/check_mk/main.mk",
+ order => 18,
}
# host_groups
if $host_groups {
@@ -78,27 +79,27 @@ class check_mk::config (
}
$groups = keys($host_groups)
check_mk::hostgroup { $groups:
- dir => "${etc_dir}/nagios/local/hostgroups",
- hostgroups => $host_groups,
- target => "${etc_dir}/check_mk/main.mk",
- notify => Exec['check_mk-refresh']
+ dir => "${etc_dir}/nagios/local/hostgroups",
+ hostgroups => $host_groups,
+ target => "${etc_dir}/check_mk/main.mk",
+ notify => Exec['check_mk-refresh']
}
}
# local config is in /omd/sites/${site}/etc/check_mk/main.mk.local and is appended
concat::fragment { 'check_mk-local-config':
- ensure => "${etc_dir}/check_mk/main.mk.local",
- target => "${etc_dir}/check_mk/main.mk",
- order => 99,
+ ensure => "${etc_dir}/check_mk/main.mk.local",
+ target => "${etc_dir}/check_mk/main.mk",
+ order => 99,
}
# re-read config if it changes
exec { 'check_mk-refresh':
- command => "/bin/su -l -c '${bin_dir}/check_mk -I' ${site}",
- refreshonly => true,
+ command => "/bin/su -l -c '${bin_dir}/check_mk -II' ${site}",
+ 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,
}
# re-read inventory at least daily
exec { 'check_mk-refresh-inventory-daily':
diff --git a/manifests/init.pp b/manifests/init.pp
index 7296941..4aab837 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -1,17 +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,
@@ -20,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'],