+ Added scheduleddowntime object. #7218

This commit is contained in:
Ricardo Melo 2014-11-04 12:40:30 -05:00
parent 19a2f5330c
commit d96a439357
3 changed files with 113 additions and 0 deletions

View file

@ -336,6 +336,7 @@ Object types:
* [icinga2::object::idomysqlconnection](id:object_idomysqlconnection)
* [icinga2::object::idopgsqlconnection](id:object_idopgsqlconnection)
* [icinga2::object::notificationcommand](id:object_notificationcommand)
* [icinga2::object::scheduleddowntime](id:object_scheduleddowntime)
* [icinga2::object::service](id:object_service)
* [icinga2::object::servicegroup](id:object_servicegroup)
* [icinga2::object::syslogger](id:object_syslogger)
@ -581,6 +582,26 @@ icinga2::object::notificationcommand { 'mail-service-notification':
This oobject use the same parameter defined to `checkcommand`.
####[`icinga2::object::sicheduleddownload`](id:object_scheduleddownload)
This defined type creates **ScheduledDowntime** objects
Example usage:
<pre>
icinga2::object::scheduleddowntime {'some-downtime':
host_name => 'localhost',
service_name => 'ping4',
author => 'icingaadmin',
comment => 'Some comment',
fixed => false,
duration => '30m',
ranges => { 'sunday' => '02:00-03:00' }
}
</pre>
####[`icinga2::object::service`](id:object_service)
Coming soon...

View file

@ -0,0 +1,54 @@
# == Defined type: icinga2::object::scheduleddowntime
#
# This is a defined type for Icinga 2 ScheduledDowntime objects.
# See the following Icinga 2 doc page for more info:
# http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-scheduleddowntime
#
# === Parameters
#
# See the inline comments.
#
define icinga2::object::scheduleddowntime (
$object_scheduleddowntimename = $name,
$host_name = undef,
$service_name = undef,
$author = undef,
$comment = undef,
$fixed = true,
$duration = undef,
$ranges = {},
$target_dir = '/etc/icinga2/objects/scheduleddowntimes',
$target_file_name = "${name}.conf",
$target_file_owner = 'root',
$target_file_group = 'root',
$target_file_mode = '0644'
) {
#Do some validation of the define's parameters:
validate_string($object_scheduleddowntimename)
validate_string($host_name)
if $service_name {
validate_string($service_name)
}
validate_string($author)
validate_string($comment)
validate_bool($fixed)
validate_string($duration)
validate_hash($ranges)
validate_string($target_dir)
validate_string($target_file_name)
validate_string($target_file_owner)
validate_string($target_file_group)
validate_string($target_file_mode)
file {"${target_dir}/${target_file_name}":
ensure => file,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_scheduleddowntime.conf.erb'),
notify => Service['icinga2'],
}
}

View file

@ -0,0 +1,38 @@
/**
* WARNING: This scheduleddowntime definition is automatically generated by Puppet.
* ANY MANUAL CHANGES TO IT WILL GET OVERWRITTEN!
*/
/**
* A ScheduledDowntime definition. You can create your own configuration files
* in the conf.d directory (e.g. one per host). By default all *.conf
* files in this directory are included.
*
*/
object ScheduledDowntime "<%= @object_scheduleddowntimename %>" {
<%#- If any of the @ parameters are undefined, don't print anything for them: -%>
host_name = "<%= @host_name -%>"
<%- if @service_name -%>
service_name = "<%= @service_name -%>"
<%- end -%>
author = "<%= @author -%>"
comment = "<%= @comment -%>"
<%- if @fixed != true -%>
fixed = false
<%- end -%>
<%- if @duration -%>
duration = <%= @duration -%>
<%- end -%>
<%- if @ranges.empty? != true -%>
ranges = {
<%- @ranges.each_pair do |key, value| -%>
"<%= key %>" = "<%= value %>"
<%- end -%>
}
<%- end -%>
}