Attributes of other nodes are not available during the first chef-client run?



I have a recipe like this:

puts node[:fqdn] # => fqdn of the node itself
n[:fqdn]zk_servers = search(:node, “cluster_name:abc AND role:zookeeper”)
quorum = zk_servers.collect { |n| n[:fqdn] }
puts quorum
* # =>** ["", “”, “”] # but expected result is
an array of fqdn* of all zookeeper nodes

This code in recipe is executed in Compile phase. Seems the node[:fqdn] or
node[:ipaddress] or other nodes is not available yet, however node[:fqdn]
of the node itself is available.

If this is true, how about saving the node to Chef Server immediately after
ohai collects the automatic attributes ? So the node can get other nodes’
fqdn and ip.

Jesse Hu @Beijing