summaryrefslogtreecommitdiff
path: root/puppet/modules/check_mk/manifests/hostgroup.pp
blob: baec45f94cbbbe8fb035300d72c1d06fe31c36e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
define check_mk::hostgroup (
  $dir,
  $hostgroups,
  $target,
) {
  $group = $title
  $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  alias ${description}\n}\n",
    require => File[$dir],
  }
}