I am trying to generate the nagios hosts.cfg file from the standard opscode nagios cookbook. Using the standard recipe I am continually getting the same errors from the following lines:
Chef::Mixin::Template::TemplateError (undefined method `[]' for nil:NilClass) on line #19:
17: if node['cloud'].nil? && !n['cloud'].nil?
18: ip = n['cloud']['public_ipv4'].include?('.') ? n['cloud']['public_ipv4'] : n['ipaddress']
19: elsif !node['cloud'].nil? && n['cloud']['provider'] != node['cloud']['provider']
20: ip = n['cloud']['public_ipv4'].include?('.') ? n['cloud']['public_ipv4'] : n['ipaddress']
21: else
22: ip = n['ipaddress']
The full File is here:
Notations on the original file were as follows:
<% # decide whether to use internal or external IP addresses for this node
# if the nagios server is not in the cloud, always use public IP addresses for cloud nodes.
# if the nagios server is in the cloud, use private IP addresses for any
# cloud servers in the same cloud, public IPs for servers in other clouds
# (where other is defined by node['cloud']['provider'])
# if the cloud IP is nil then use the standard IP address attribute. This is a work around
# for OHAI incorrectly identifying systems on Cisco hardware as being in Rackspace