我需要找到一个节点的 IP,如果有的话。问题是“cluster_nodes.first”没问题,但它没有任何方法,“.ip”不存在,cluster_nodes.first[:ip] 也不存在,我在 Chef Wiki 上找不到任何信息。
cluster_nodes = search(:node, "name:cluster1*")
if cluster_nodes.size > 0
node[:primary_node] = cluster_nodes.first.ip
else
node[:primary_node] = ''
end
错误:
[Sat, 01 Sep 2012 10:29:22 +0000] ERROR: Running exception handlers
[Sat, 01 Sep 2012 10:29:22 +0000] FATAL: Saving node information to /var/chef/cache/failed-run-data.json
[Sat, 01 Sep 2012 10:29:22 +0000] ERROR: Exception handlers complete
[Sat, 01 Sep 2012 10:29:22 +0000] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[Sat, 01 Sep 2012 10:29:22 +0000] FATAL: ArgumentError: Attribute ip is not defined!