You can 'node.save' in your Recipe DSL compile phase if you absolutely require that the partially compiled/non-converged Node attributes are stored/indexed without a full convergence run.I wouldn't recommend this -- How do you know the compile phase node.save reflects the actual desired state of the search results? You're essentially saying, "Hey, index me as a 'blah' node. I know I'm not done yet... but I *could* be, in the future, some time! Or not."Cheers,AJOn 12 November 2012 21:37, Hui Hu < " target="_blank"> > wrote:
Hi,
I have a recipe like this:
puts node[:fqdn] # => fqdn of the node itselfThis 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.
n[:fqdn]zk_servers = search(:node, "cluster_name:abc AND role:zookeeper")
quorum = zk_servers.collect { |n| n[:fqdn] }
puts quorum..to_s # => ["", "", ""] # but expected result is an array of fqdn of all zookeeper nodes
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.
Thanks
Jesse Hu @Beijing
Archive powered by MHonArc 2.6.16.