[icinga-checkins] icinga.org: puppet-icinga2/master: + Added scheduleddowntime object. #7218

git at icinga.org git at icinga.org
Mon Nov 17 06:37:24 CET 2014


Module: puppet-icinga2
Branch: master
Commit: d96a439357514a7edd0d2def9563930ecaa491b9
URL:    https://git.icinga.org/?p=puppet-icinga2.git;a=commit;h=d96a439357514a7edd0d2def9563930ecaa491b9

Author: Ricardo Melo <ricardo.melo at gameloft.com>
Date:   Tue Nov  4 12:40:30 2014 -0500

+ Added scheduleddowntime object. #7218

---

 README.md                                   |   21 +++++++++++
 manifests/object/scheduleddowntime.pp       |   54 +++++++++++++++++++++++++++
 templates/object_scheduleddowntime.conf.erb |   38 +++++++++++++++++++
 3 files changed, 113 insertions(+)

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:
+
+<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...
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 -%>
+}



More information about the icinga-checkins mailing list