【发布时间】:2013-04-10 03:24:39
【问题描述】:
我正在尝试从标准操作码 nagios 食谱生成 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
【问题讨论】:
-
能否请您提供有关您的节点配置的相关信息?你有
node['cloud']设置吗?你想达到什么目的? -
我在寻找节点“云”,但它不是一个属性,但它看起来确实是我看过的其他 SO 的搜索选项。 /n 根据原始文档,这也在上下文中。 (添加上面的大小)
-
请不要忘记将答案标记为正确! :)
标签: ruby amazon-web-services chef-infra nagios cookbook