summaryrefslogtreecommitdiff
path: root/manifests/config.pp
diff options
context:
space:
mode:
authorKeith Burdis <keith@burdis.org>2013-02-08 14:24:09 +0000
committerKeith Burdis <keith@burdis.org>2013-02-08 14:24:09 +0000
commit8d8887c4ee333b620bdfb0a4c5888efb88f48493 (patch)
tree4e099d4f6933980ffd8e4c69cfd4ba60c2e9856a /manifests/config.pp
parente2dbf51aaae246e3b8e5d07c01cacac2ed4477ee (diff)
* Switched to using OMD rather than manually compiling check_mk
* Added support for host tags and creating host groups based on these tags * Allow local check_mk configuration to be specified in /etc/check_mk/main.mk.local that is appended to /etc/check_mk/main.mk as check_mk can do a lot more than is covered by this module
Diffstat (limited to 'manifests/config.pp')
-rw-r--r--manifests/config.pp78
1 files changed, 59 insertions, 19 deletions
diff --git a/manifests/config.pp b/manifests/config.pp
index 14dc873..c25fd1a 100644
--- a/manifests/config.pp
+++ b/manifests/config.pp
@@ -1,46 +1,86 @@
-class check_mk::config {
- file_line { 'nagios-remove-localhost':
- ensure => absent,
- line => 'cfg_file=/etc/nagios/objects/localhost.cfg',
- path => '/etc/nagios/nagios.cfg',
- notify => Class['check_mk::service'],
+class check_mk::config (
+ site,
+ host_groups = undef,
+) {
+ $etc_dir = "/omd/sites/${site}/etc"
+ $bin_dir = "/omd/sites/${site}/bin"
+ exec { 'omd-create-site':
+ command => "/usr/bin/omd create ${site}",
+ creates => $etc_dir,
+ }
+ file { "${etc_dir}/nagios/local":
+ ensure => directory,
}
file_line { 'nagios-add-check_mk-cfg_dir':
- ensure => present,
- line => 'cfg_dir=/etc/nagios/check_mk',
- path => '/etc/nagios/nagios.cfg',
- notify => Class['check_mk::service'],
+ ensure => present,
+ line => "cfg_dir=${etc_dir}/nagios/local",
+ path => "${etc_dir}/nagios/nagios.cfg",
+ require => File["${etc_dir}/nagios/local"],
+ notify => Class['check_mk::service'],
}
file_line { 'add-guest-users':
ensure => present,
line => 'guest_users = [ "guest" ]',
- path => '/etc/check_mk/multisite.mk',
+ path => "${etc_dir}/check_mk/multisite.mk",
notify => Class['check_mk::service'],
}
- concat { '/etc/check_mk/main.mk':
+ concat { "${etc_dir}/check_mk/main.mk":
owner => 'root',
group => 'root',
mode => '0644',
notify => Exec['check_mk-refresh'],
}
+ # all_hosts
concat::fragment { 'all_hosts-header':
- target => '/etc/check_mk/main.mk',
+ target => "${etc_dir}/check_mk/main.mk",
content => "all_hosts = [\n",
- order => 01,
+ order => 10,
}
concat::fragment { 'all_hosts-footer':
- target => '/etc/check_mk/main.mk',
+ target => "${etc_dir}/check_mk/main.mk",
content => "]\n",
- order => 03,
+ order => 19,
+ }
+ Check_mk::Host <<| |>> {
+ target => "${etc_dir}/check_mk/main.mk",
+ notify => Exec['check_mk-refresh']
+ }
+ # host_groups
+ if $host_groups {
+ file { "${etc_dir}/nagios/local/hostgroups":
+ ensure => directory,
+ }
+ concat::fragment { 'host_groups-header':
+ target => "${etc_dir}/check_mk/main.mk",
+ content => "host_groups = [\n",
+ order => 20,
+ }
+ concat::fragment { 'host_groups-footer':
+ target => "${etc_dir}/check_mk/main.mk",
+ content => "]\n",
+ order => 29,
+ }
+ check_mk::hostgroup { keys($host_groups):
+ dir => "${etc_dir}/nagios/local/hostgroups",
+ host_groups => $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':
+ target => "${etc_dir}/check_mk/main.mk",
+ ensure => "${etc_dir}/check_mk/main.mk.local",
+ order => 99,
}
- Check_mk::Host <<| |>> { notify => Exec['check_mk-refresh'] }
+ # re-read config
exec { 'check_mk-refresh':
- command => '/usr/bin/check_mk -I',
+ command => "${bin_dir}/check_mk -I",
refreshonly => true,
notify => Exec['check_mk-reload'],
}
exec { 'check_mk-reload':
- command => '/usr/bin/check_mk -O',
+ command => "${bin_dir}/check_mk -O",
refreshonly => true,
}
}