Giuseppe Lavagetto has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/164301

Change subject: nagios_common: use a template for contacts.
......................................................................

nagios_common: use a template for contacts.

By using a template, we'll guarantee us that we can save the private
data of all the notified people in the private hiera repo only, under
nagios_common::contacts::contacts

Change-Id: I7ce1715104e64c77afb6b08d1084c5befea1591a
Signed-off-by: Giuseppe Lavagetto <glavage...@wikimedia.org>
---
M modules/nagios_common/manifests/contacts.pp
A modules/nagios_common/templates/contacts.cfg.erb
2 files changed, 25 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/01/164301/1

diff --git a/modules/nagios_common/manifests/contacts.pp 
b/modules/nagios_common/manifests/contacts.pp
index 2792d2d..0565e04 100644
--- a/modules/nagios_common/manifests/contacts.pp
+++ b/modules/nagios_common/manifests/contacts.pp
@@ -10,9 +10,9 @@
 #   The base directory to put configuration directory in.
 #   Defaults to '/etc/icinga/'
 #
-# [*source*]
-#   puppet URL specifying the source of the contacts.cfg
-#   Defaults to 'puppet:///modules/nagios_common/contacts.cfg'
+# [*template*]
+#   puppet URL specifying the template of the contacts.cfg file
+#   Defaults to 'nagios_common/contacts.cfg.erb'
 #
 # [*owner*]
 #   The user which should own the check config files.
@@ -22,16 +22,20 @@
 #   The group which should own the check config files.
 #   Defaults to 'root'
 #
+# [*contacts*]
+#   The list of contacts to include in the configuration.
+#
 class nagios_common::contacts(
     $ensure = present,
     $config_dir = '/etc/icinga',
-    $source = 'puppet:///modules/nagios_common/contacts.cfg',
+    $template = 'nagios_common/contacts.cfg.erb',
     $owner = 'root',
     $group = 'root',
+    $contacts = [],
 ) {
     file { "$config_dir/contacts.cfg":
         ensure => $ensure,
-        source => $source,
+        content => template($template),
         owner  => $owner,
         group  => $group,
     }
diff --git a/modules/nagios_common/templates/contacts.cfg.erb 
b/modules/nagios_common/templates/contacts.cfg.erb
new file mode 100644
index 0000000..a80971b
--- /dev/null
+++ b/modules/nagios_common/templates/contacts.cfg.erb
@@ -0,0 +1,16 @@
+<%- @contacts.each do |contact| -%>
+<%- period = contact.include? 'period' ? contact['period'] : '24x7' -%>
+<%- email = contact.include? 'email' ? contact['email'] : 'nowhere' -%>
+<%- commands = contact.include? 'commands' ? contact['commands']: ['by-email'] 
-%>
+define contact{
+        contact_name                    <%= contact['name'] %>
+        alias                           <%= contact['alias'] %>
+        host_notification_period        <%= period %>
+        service_notification_period     <%= period %>
+        host_notification_options       d,u,r,f
+        service_notification_options    c,r,f
+        email                           <%= email %>
+        host_notification_commands      <%= commands.map{|v| 
"host-notify-#{v}"}.join(',') %>
+        service_notification_commands   <%= commands.map{|v| 
"host-notify-#{v}"}.join(',') %>
+}
+<% end %>

-- 
To view, visit https://gerrit.wikimedia.org/r/164301
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7ce1715104e64c77afb6b08d1084c5befea1591a
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Giuseppe Lavagetto <glavage...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to