2014-07-21 05:40:22 +02:00
|
|
|
# == Defined type: icinga2::object::hostgroup
|
|
|
|
#
|
2014-07-29 03:49:09 +02:00
|
|
|
# This is a defined type for Icinga 2 hostgroup objects.
|
|
|
|
# See the following Icinga 2 doc page for more info:
|
|
|
|
# http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-hostgroup
|
2014-07-21 05:40:22 +02:00
|
|
|
#
|
|
|
|
# === Parameters
|
|
|
|
#
|
|
|
|
# See the inline comments.
|
|
|
|
#
|
|
|
|
|
2014-07-27 02:07:03 +02:00
|
|
|
define icinga2::object::hostgroup (
|
2014-07-21 05:40:22 +02:00
|
|
|
$object_hostgroup_name = $name,
|
|
|
|
$display_name = $name,
|
|
|
|
$template_to_import = undef,
|
|
|
|
$groups = [],
|
2014-11-22 06:24:05 +01:00
|
|
|
$target_dir = '/etc/icinga2/objects',
|
2014-07-21 05:40:22 +02:00
|
|
|
$target_file_name = "${name}.conf",
|
2014-11-19 06:55:48 +01:00
|
|
|
$target_file_ensure = file,
|
2014-07-21 05:40:22 +02:00
|
|
|
$target_file_owner = 'root',
|
|
|
|
$target_file_group = 'root',
|
2014-09-26 21:01:51 +02:00
|
|
|
$target_file_mode = '0644',
|
2014-07-30 02:21:10 +02:00
|
|
|
$assign_where = undef,
|
2014-12-02 06:38:42 +01:00
|
|
|
$ignore_where = undef,
|
|
|
|
$refresh_icinga2_service = true
|
2014-07-21 05:40:22 +02:00
|
|
|
) {
|
|
|
|
|
2014-09-07 03:44:12 +02:00
|
|
|
#Do some validation of the class' parameters:
|
|
|
|
validate_string($object_hostgroup_name)
|
|
|
|
validate_string($template_to_import)
|
2014-09-26 20:55:44 +02:00
|
|
|
validate_string($display_name)
|
2014-09-07 03:44:12 +02:00
|
|
|
validate_array($groups)
|
|
|
|
validate_string($target_dir)
|
|
|
|
validate_string($target_file_name)
|
|
|
|
validate_string($target_file_owner)
|
|
|
|
validate_string($target_file_group)
|
|
|
|
validate_string($target_file_mode)
|
2014-12-02 06:38:42 +01:00
|
|
|
validate_bool($refresh_icinga2_service)
|
2014-09-07 03:44:12 +02:00
|
|
|
|
2014-12-02 06:38:42 +01:00
|
|
|
#If the refresh_icinga2_service parameter is set to true...
|
|
|
|
if $refresh_icinga2_service == true {
|
|
|
|
|
|
|
|
file { "${target_dir}/${target_file_name}":
|
|
|
|
ensure => $target_file_ensure,
|
|
|
|
owner => $target_file_owner,
|
|
|
|
group => $target_file_group,
|
|
|
|
mode => $target_file_mode,
|
|
|
|
content => template('icinga2/object_hostgroup.conf.erb'),
|
|
|
|
#...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file...
|
|
|
|
notify => Service['icinga2'],
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
#...otherwise, use the same file resource but without a notify => parameter:
|
|
|
|
else {
|
|
|
|
|
|
|
|
file { "${target_dir}/${target_file_name}":
|
|
|
|
ensure => $target_file_ensure,
|
|
|
|
owner => $target_file_owner,
|
|
|
|
group => $target_file_group,
|
|
|
|
mode => $target_file_mode,
|
|
|
|
content => template('icinga2/object_hostgroup.conf.erb'),
|
|
|
|
}
|
|
|
|
|
2014-07-21 05:40:22 +02:00
|
|
|
}
|
|
|
|
|
2014-09-14 04:46:24 +02:00
|
|
|
}
|