From d96a439357514a7edd0d2def9563930ecaa491b9 Mon Sep 17 00:00:00 2001 From: Ricardo Melo Date: Tue, 4 Nov 2014 12:40:30 -0500 Subject: [PATCH 1/2] + Added scheduleddowntime object. #7218 --- README.md | 21 ++++++++ manifests/object/scheduleddowntime.pp | 54 +++++++++++++++++++++ templates/object_scheduleddowntime.conf.erb | 38 +++++++++++++++ 3 files changed, 113 insertions(+) create mode 100644 manifests/object/scheduleddowntime.pp create mode 100644 templates/object_scheduleddowntime.conf.erb diff --git a/README.md b/README.md index d8af224..8820d5f 100644 --- a/README.md +++ b/README.md @@ -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: + +
+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' }
+}
+
+ + + ####[`icinga2::object::service`](id:object_service) Coming soon... diff --git a/manifests/object/scheduleddowntime.pp b/manifests/object/scheduleddowntime.pp new file mode 100644 index 0000000..65db762 --- /dev/null +++ b/manifests/object/scheduleddowntime.pp @@ -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'], + } + +} diff --git a/templates/object_scheduleddowntime.conf.erb b/templates/object_scheduleddowntime.conf.erb new file mode 100644 index 0000000..4793aeb --- /dev/null +++ b/templates/object_scheduleddowntime.conf.erb @@ -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 -%> +} From a52b14d4a18b0ff8b98a14128ed07a0529c3081a Mon Sep 17 00:00:00 2001 From: Ricardo Melo Date: Tue, 11 Nov 2014 18:28:23 -0500 Subject: [PATCH 2/2] * fixed typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8820d5f..788bc24 100644 --- a/README.md +++ b/README.md @@ -582,7 +582,7 @@ icinga2::object::notificationcommand { 'mail-service-notification': This oobject use the same parameter defined to `checkcommand`. -####[`icinga2::object::sicheduleddownload`](id:object_scheduleddownload) +####[`icinga2::object::scheduleddownload`](id:object_scheduleddownload) This defined type creates **ScheduledDowntime** objects