我正在尝试从标准的opscode nagios cookbook生成nagios hosts.cfg文件。使用标准配方我不断从以下几行得到相同的错误:
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']
完整档案在这里:
原始文件上的注释如下:
<% # 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
答案 0 :(得分:0)
我没有尝试解决这个问题,而是采取了以下解决方法:
define host {
use server
address <%= node['ipaddress'] %>
host_name <%= node[node['nagios']['host_name_attribute']] %>
hostgroups <%= node['nagios']['server_role'] %>,<%= node['os'] %>
}
这不是使用cloud ip configs。