3
我需要找到一個節點的IP,如果有的話。問題是'cluster_nodes.first'沒問題,但它沒有任何方法,'.ip'不存在,cluster_nodes.first [:ip]也沒有,我在Chef Wiki上找不到任何信息。如何在Chef配方中動態查找主機的IP
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!