[chef] debugging recipe for a specific incorrect file


Chronological Thread 
  • From: Nikhil Shah < >
  • To: " " < >
  • Subject: [chef] debugging recipe for a specific incorrect file
  • Date: Tue, 4 Aug 2015 17:21:35 -0400

I've fried my brain going thru each configs and I can't for the life of me figure out where i messed up the configs. Is there a way to debug this within the recipe? I've checked data bags and roles and it seems like the error is saying I have a null value as hostgroup, but I don't see anything. 




Recipe Compile Error in /var/chef/cache/cookbooks/nagios/recipes/server.rb
================================================================================

NoMethodError
-------------
undefined method `each' for nil:NilClass

Cookbook Trace:
---------------
  /var/chef/cache/cookbooks/nagios/recipes/server.rb:156:in `block in from_file'
  /var/chef/cache/cookbooks/nagios/recipes/server.rb:155:in `each'
  /var/chef/cache/cookbooks/nagios/recipes/server.rb:155:in `from_file'

Relevant File Content:
----------------------
/var/chef/cache/cookbooks/nagios/recipes/server.rb:
149:  unmanaged_hosts = nagios_bags.get('nagios_unmanagedhosts')
150:  serviceescalations = nagios_bags.get('nagios_serviceescalations')
151:  contacts = nagios_bags.get('nagios_contacts')
152:  contactgroups = nagios_bags.get('nagios_contactgroups')
153:  
154:  # Add unmanaged host hostgroups to the hostgroups array if they don't already exist
155:  unmanaged_hosts.each do |host|
156>>   host['hostgroups'].each do |hg|
157:      if !hostgroups.include?(hg)
158:        hostgroups << hg
159:      end
160:    end
161:  end
162:  
163:  # Load search defined Nagios hostgroups from the nagios_hostgroups data bag and find nodes
164:  hostgroup_nodes= Hash.new
165:  hostgroup_list = Array.new


[2015-08-04T17:05:01-04:00] ERROR: Running exception handlers
[2015-08-04T17:05:01-04:00] ERROR: Exception handlers complete
[2015-08-04T17:05:01-04:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
Chef Client failed. 0 resources updated
[2015-08-04T17:05:01-04:00] ERROR: undefined method `each' for nil:NilClass
[2015-08-04T17:05:01-04:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
You have new mail in /var/spool/mail/root


--
Nikhil Shah  System Administrator

THE ORCHARD Distribution Done Right
23 E 4th St Fl 3, New York, NY 10003

Follow us: The Daily Rind  Facebook  Twitter  YouTube  LinkedIn

Privileged And Confidential Communication. This electronic transmission, and any documents attached hereto, (a) are protected by the Electronic Communications Privacy Act (18 USC §§ 2510-2521), (b) may contain confidential and/or legally privileged information, and (c) are for the sole use of the intended recipient named above. If you have received this electronic message in error, please notify the sender and delete the electronic message. Any disclosure, copying, distribution, or use of the contents of the information received in error is strictly prohibited.



Archive powered by MHonArc 2.6.16.

§