1

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:

http://pastebin.com/FqcdUnSE

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
4

1 回答 1

0

Instead of trying to fix this, I did the following workaround:

    define host {
    use server
    address <%= node['ipaddress'] %>
    host_name <%= node[node['nagios']['host_name_attribute']] %>
    hostgroups <%= node['nagios']['server_role'] %>,<%= node['os'] %>
    }

This worked instead of using the cloud ip configs.

于 2013-04-09T19:24:39.413 回答