[icinga-checkins] icinga.org: puppet-icinga2/master: adding define and template to generate timeperiods

git at icinga.org git at icinga.org
Wed Nov 12 06:50:10 CET 2014


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

Author: Steven Bambling <smbambling at gmail.com>
Date:   Tue Nov  4 07:39:18 2014 -0500

adding define and template to generate timeperiods

Signed-off-by: Nick Chappell <nick at intronic.org>

Merged from: https://github.com/Icinga/puppet-icinga2/pull/37

refs#7217: https://dev.icinga.org/issues/7217

---

 manifests/object/timeperiod.pp       |   42 ++++++++++++++++++++++++++++++++++
 templates/object_timeperiod.conf.erb |   24 +++++++++++++++++++
 2 files changed, 66 insertions(+)

diff --git a/manifests/object/timeperiod.pp b/manifests/object/timeperiod.pp
new file mode 100644
index 0000000..8d63a41
--- /dev/null
+++ b/manifests/object/timeperiod.pp
@@ -0,0 +1,42 @@
+# == Defined type: icinga2::object::timeperiod
+#
+#  This is a defined type for Icinga 2 host objects.
+# See the following Icinga 2 doc page for more info:
+# http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/monitoring-basics#timeperiods
+#
+# === Parameters
+#
+# See the inline comments.
+#
+
+define icinga2::object::timeperiod (
+  $object_timeperiod_name       = $name,
+  $timeperiod_display_name      = undef,
+  $timeperiod_ranges            = {},
+  $timeperiod_target_dir        = '/etc/icinga2/objects/timeperiods',
+  $timeperiod_target_file_name  = "${name}.conf",
+  $timeperiod_target_file_owner = 'root',
+  $timeperiod_target_file_group = 'root',
+  $timeperiod_target_file_mode  = '0644',
+) {
+
+  # Do some validation of the class' parameters:
+  validate_string($object_timeperiod_name)
+  validate_string($timeperiod_display_name)
+  validate_hash($timeperiod_ranges)
+  validate_string($timeperiod_target_dir)
+  validate_string($timeperiod_target_file_name)
+  validate_string($timeperiod_target_file_owner)
+  validate_string($timeperiod_target_file_group)
+  validate_re($timeperiod_target_file_mode, '^\d{4}$')
+
+  file {"${timeperiod_target_dir}/${timeperiod_target_file_name}":
+    ensure  => file,
+    owner   => $timeperiod_target_file_owner,
+    group   => $timeperiod_target_file_group,
+    mode    => $timeperiod_target_file_mode,
+    content => template('icinga2/object_timeperiod.conf.erb'),
+    notify  => Service['icinga2'],
+  }
+  
+}
diff --git a/templates/object_timeperiod.conf.erb b/templates/object_timeperiod.conf.erb
new file mode 100644
index 0000000..c5bf7f4
--- /dev/null
+++ b/templates/object_timeperiod.conf.erb
@@ -0,0 +1,24 @@
+/**
+* WARNING: This NotificationCommand definition is automatically generated by Puppet.
+* ANY MANUAL CHANGES TO IT WILL GET OVERWRITTEN!
+*/
+
+/**
+* A TimePeriod definition. You can create your own configuration files
+* in the conf.d directory (e.g. one per commnand). By default all *.conf
+* files in this directory are included.
+*
+*/
+
+object TimePeriod "<%= @object_timeperiod_name %>" {
+  import "legacy-timepriod"
+
+  display_name = "<%= @timeperiod_display_name %>"
+  <%- if @timeperiod_ranges.empty? != true -%>
+  ranges = {
+  <%- @timeperiod_ranges.each_pair do |key,value| -%>>
+    "<%= key %>" = "<%= value %>"
+  <%- end -%>
+  }
+  <%- end -%> 
+}



More information about the icinga-checkins mailing list