[chef] Re: Nagios cookbook requires non-standard attributes within the "users" data bag for admins?


Chronological Thread 
  • From: Erik Sabowski < >
  • To:
  • Subject: [chef] Re: Nagios cookbook requires non-standard attributes within the "users" data bag for admins?
  • Date: Thu, 22 Sep 2011 18:52:30 -0400
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=sabowski.com; h=message-id:date :from:mime-version:to:subject:references:in-reply-to :content-type:content-transfer-encoding; q=dns; s=sabowski.com; b=QhBWDRN/zAK+FlUCKrT5nkX9xEqwjV99L/W1pFRehYMSr5I6SYSAgss44f3fx gM6c3if374QoRvyUA00hTghf3lq9YodhGJ5d4jlAX3MAlRmuC68mRCazrijTMLlG Rq2C3KG/PigU/QvJMYLBkgaJ6k8jmVeMc7mGjCiICXdqC0=

On 09/22/2011 05:52 PM, Brad Knowles wrote:
Folks,

This is another one where I had opened a discussion on this subject at 
help.opscode.com, and where I am now moving this thread to this list instead.


Anyway, I have been following as best I can the Nagios quick start tutorial 
(seeing as I'm on CentOS 5.6 and not Ubuntu, this means there's a lot of 
stuff I have to do differently), and it seems that the file 
nagios/templates/default/contacts.cfg.erb requires some non-standard 
attributes to be defined for the admins (I added line numbers to make it 
easier to see what error was happening where):

  25<% @admins.each do |a| -%>
  26 define contact {
  27   use          default-contact
  28   contact_name<%= a['id'] %>
  29   email<%= a['nagios']['email'] %>
  30 }

However, in the "users" data bag, the attribute ['nagios']['email'] is not 
defined for any of our admins. So, this value is nil, and we get this error when trying 
to install this cookbook:

[Thu, 22 Sep 2011 17:52:14 +0000] INFO: Processing 
template[/etc/nagios3/conf.d/contacts.cfg] action create (nagios::server line 
28)
[Thu, 22 Sep 2011 17:52:14 +0000] ERROR: 
template[/etc/nagios3/conf.d/contacts.cfg] (nagios::server line 28) has had 
an error
[Thu, 22 Sep 2011 17:52:14 +0000] ERROR: 
template[/etc/nagios3/conf.d/contacts.cfg] 
(/var/chef/cache/cookbooks/nagios/definitions/nagios_conf.rb:28:in `block in 
from_file') had an error:
Chef::Mixin::Template::TemplateError (undefined method `[]' for nil:NilClass) 
on line #29:

  27:   use          default-contact
  28:   contact_name<%= a['id'] %>
  29:   email<%= a['nagios']['email'] %>
  30: }
  31:

Correct me if I'm wrong, but is this template assuming that all admins should 
get all nagios notices sent by e-mail? What if we have several admins defined 
on the machine but who should not get the notices?

Assuming I'm correct, then shouldn't you test a['nagios']['email'] != nil 
before you try to use it in an assignment on line 29, and if it is nil then 
skip over this particular admin?


Unfortunately, this issue is preventing me from installing the Nagios 
cookbook from the Opscode repository.  I'm now moving on to try the icinga 
cookbook, to see if that works any better.

Any and all advice or suggestions would be appreciated.  Thanks!


It really shouldn't be too hard to change that. You could add another field to the data bag indicating if this person should get notifications. Then add some logic to add only those people to the contact group. The rest of the users in the data bag will still be able to log in to the interface because that access is set somewhere else.

Note that those users would still have admin access to the server. If you want to create read-only users you'd have to modify it a bit more and create a separate contact group for read only users.

I don't think that these community cookbooks are meant to be everything to everyone, but rather a good starting point for most people to build on.

-erik



Archive powered by MHonArc 2.6.16.

§