diff options
-rw-r--r-- | Changelog | 10 | ||||
-rw-r--r-- | Modulefile | 2 | ||||
-rw-r--r-- | README.md | 52 | ||||
-rw-r--r-- | manifests/agent.pp | 5 | ||||
-rw-r--r-- | manifests/config.pp | 8 | ||||
-rw-r--r-- | manifests/hostgroup.pp | 10 | ||||
-rw-r--r-- | manifests/init.pp | 14 |
7 files changed, 90 insertions, 11 deletions
@@ -1,3 +1,13 @@ +0.3.0: + +* Added host tags to agent config so that host groups can be auto-populated + +* Fixed incorrect package name when using a file store that was causing the +package existence check to fail always causing an often failing reinstall + +* Enable a static list of hosts to be specified for those without the Puppet +check_mk module installed + 0.2.0: * Switched to using OMD rather than manually compiling check_mk @@ -1,5 +1,5 @@ name 'erwbgy-check_mk' -version '0.2.0' +version '0.3.0' source 'https://github.com/erwbgy/puppet-check_mk.git' author 'erwbgy' license 'Apache License, Version 2.0' @@ -50,6 +50,8 @@ created making the URL http://hostname/acme/check_mk/ running as the 'acme' user *filestore*: The Puppet file store location where the package can be found (eg. 'puppet:///files/check_mk'). Optional. +*host_groups*: A hash with the host group names as the keys with a list of host tags to match as values. (See Host Tags below). Optional. + *site*: The name of the omd site (and the user/group it runs as). Default: 'monitoring' *workspace*: The directory to use to store files used during installation. Default: '/root/check_mk' @@ -66,6 +68,8 @@ created making the URL http://hostname/acme/check_mk/ running as the 'acme' user * A user called 'guest' is configured as a guest user but is not enabled unless a password is set (as above). +* RedHat-like RPM downloads from http://omdistro.org/projects/omd-redhat/files + ## Agent * Installs the check_mk-agent and check_mk-agent-logwatch packages @@ -116,3 +120,51 @@ Only required if a filestore is used. *workspace*: The directory to use to store files used during installation. Default: '/root/check_mk' +## Host groups and tags + +By default check_mk puts all hosts into a group called 'check_mk' but where you +have more than a few you will often want your own groups. We can do this by +setting host tags on the agents and then configuring hos groups on the server +side to match hosts with these tags. + +For example in the hiera config for your agent hosts you could have: + + check_mk::agent::host_tags: + - '%{osfamily}' + +and on the monitoring host you could have: + + check_mk::host_groups: + RedHat: + description: 'RedHat or_CentOS hosts' + host_tags: + - RedHat + Debian: + description: 'Debian or Ubuntu_hosts' + host_tags: + - Debian + SuSE: + description: 'SuSE hosts' + host_tags: + - Suse + +You can of course have as many host tags as you like. I have custom facts for +the server role and the environment type (dev, qa, stage, prod) and define +groups based on the role and envtype. + +## Static host config + +Hosts that do not run Puppet with the check_mk module are not automatically +added to the all_hosts list in main.mk. To manually include these hosts you can +add them to '/omd/sites/monitoring/etc/check_mk/all_hosts_static' (replacing +'monitoring' with your site name). Use the quoted fully qualified domain name +with a two-space prefix and a comma suffix - for example: + + 'host1.domain', + 'host2.domain', + +You can also include host tags - for example: + + 'host1.domain|windows|dev', + 'host2.domain|windows|prod', + diff --git a/manifests/agent.pp b/manifests/agent.pp index dc13388..b53882a 100644 --- a/manifests/agent.pp +++ b/manifests/agent.pp @@ -1,5 +1,6 @@ class check_mk::agent ( $filestore = undef, + $host_tags = undef, $ip_whitelist = undef, $port = '6556', $server_dir = '/usr/bin', @@ -22,5 +23,7 @@ class check_mk::agent ( require => Class['check_mk::agent::install'], } include check_mk::agent::service - @@check_mk::host { $::fqdn: } + @@check_mk::host { $::fqdn: + host_tags => $host_tags, + } } diff --git a/manifests/config.pp b/manifests/config.pp index edd14d9..73e4882 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -41,6 +41,12 @@ class check_mk::config ( target => "${etc_dir}/check_mk/main.mk", notify => Exec['check_mk-refresh'] } + # 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, + } # host_groups if $host_groups { file { "${etc_dir}/nagios/local/hostgroups": @@ -59,7 +65,7 @@ class check_mk::config ( $groups = keys($host_groups) check_mk::hostgroup { $groups: dir => "${etc_dir}/nagios/local/hostgroups", - host_groups => $host_groups, + hostgroups => $host_groups, target => "${etc_dir}/check_mk/main.mk", notify => Exec['check_mk-refresh'] } diff --git a/manifests/hostgroup.pp b/manifests/hostgroup.pp index ac66a16..baec45f 100644 --- a/manifests/hostgroup.pp +++ b/manifests/hostgroup.pp @@ -4,15 +4,21 @@ define check_mk::hostgroup ( $target, ) { $group = $title - $group_tags = join($hostgroups[$group], ',') + $group_tags = sprintf("'%s'", join($hostgroups[$group]['host_tags'], "', '")) concat::fragment { "check_mk-hostgroup-${group}": target => $target, content => " ( '${group}', [ ${group_tags} ], ALL_HOSTS ),\n", order => 21, } + if $hostgroups[$group]['description'] { + $description = $hostgroups[$group]['description'] + } + else { + $description = regsubst($group, '_', ' ') + } file { "${dir}/${group}.cfg": ensure => present, - content => "define hostgroup {\n hostgroup_name ${group}\n}\n", + content => "define hostgroup {\n hostgroup_name ${group}\n alias ${description}\n}\n", require => File[$dir], } } diff --git a/manifests/init.pp b/manifests/init.pp index 2686f55..24e4e0d 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,8 +1,9 @@ class check_mk ( - $filestore = undef, - $package = 'omd', - $site = 'monitoring', - $workspace = '/root/check_mk', + $filestore = undef, + $host_groups = undef, + $package = 'omd-0.56', + $site = 'monitoring', + $workspace = '/root/check_mk', ) { class { 'check_mk::install': filestore => $filestore, @@ -11,8 +12,9 @@ class check_mk ( workspace => $workspace, } class { 'check_mk::config': - site => $site, - require => Class['check_mk::install'], + host_groups => $host_groups, + site => $site, + require => Class['check_mk::install'], } class { 'check_mk::service': require => Class['check_mk::config'], |