[chef] Using a variable populated below in a resource defined above


Chronological Thread 
  • From: Chaim Keren-Tzion < >
  • To: chef < >
  • Subject: [chef] Using a variable populated below in a resource defined above
  • Date: Sun, 25 Aug 2013 18:47:33 +0300

I have a case where I assign a variable "known_nodes" in a resource but need to use it on another resource which I've defined above that one, and set the action to ':nothing', and am calling it from below. This does not work since the code is executed in order from top to bottom.

How could I do this properly? Here is the code:

TAI

cluster_name = node["cluster_name"]
separator=","
known_nodes=self.node['ipaddress']

cluster_rebal "MainCluster" do
        knownNodes known_nodes
        action :nothing
end

node['member_ips'].each do |node_name,node_ip|
  if node_ip != self.node['ipaddress']
    known_nodes=known_nodes+separator+"#{node_ip}"
    add_node "#{cluster_name}" do
      hostname node_ip
      notifies :rebalance, "cluster_rebal[MainCluster]", :immediately
    end
  end
end



Archive powered by MHonArc 2.6.16.

§