[chef-dev] Re: attributes of other nodes are not available during the first chef-client run ?


Chronological Thread 
  • From: Hui Hu < >
  • To: AJ Christensen < >,
  • Subject: [chef-dev] Re: attributes of other nodes are not available during the first chef-client run ?
  • Date: Tue, 13 Nov 2012 10:16:15 +0800

Thanks AJ.  Your solution 'node.save' indeed works.  For the user case that getting fqdn or ip of other nodes (in the same cluster)  in the recipe, we need to do 'node.save' at the very beginning of running recipes.

It would be useful If we can let chef-client same automatic attributes (including fqdn, ip, etc.) right after it completes ohai execution.  Any side effect of saving automatic attributes into chef nodes on Chef Server before really running the recipes ?

Thanks & Best Regards,
Hui Hu,  Beijing,  China


2012/11/13 AJ Christensen < " target="_blank"> >
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,

AJ


On 12 November 2012 21:37, Hui Hu < " target="_blank"> > wrote:
Hi,

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..to_s  # => ["", "", ""]   # 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.

Thanks
Jesse Hu  @Beijing





Archive powered by MHonArc 2.6.16.

§