[chef] Re: Re: Re: Re: Re: more of a ruby problem


Chronological Thread 
  • From: Daniel DeLeo < >
  • To:
  • Subject: [chef] Re: Re: Re: Re: Re: more of a ruby problem
  • Date: Wed, 30 Oct 2013 08:55:07 -0700


On Wednesday, October 30, 2013 at 1:16 AM, Manoj Thakkar wrote:

Sorry for asking it , but i am stuck again , looks like i am not able to read the variable i got from ruby_block

i am not sure what's wrong :


ruby_block "acc-deploy-host" do
block do
Chef::Log.info " host name is #{node['hostname']} "
host=node['hostname']
puts " hostname is #{host}"

File.open("/local_app/account-rest.properties", "r").each_line do |line|
Chef::Log.info "#{host} Account Rest line: #{line}"
  if line.include?(host)
    Chef::Log.info "Found host #{host} in #{line}"
    deploy = line.split(':').last
    deploy = deploy.gsub(/\n/," ")
    node.set['account_deploy']=deploy
    Chef::Log.info "Found account value #{node['account_deploy']}"
end
end
end

node['account_deploy'].each do |x|

puts #x

end
end
An important thing to keep in mind about Ruby blocks is that it may or may not be executed at a different time than the surrounding code. In this case, Chef holds on to the code you pass into `block do` so it can evaluate it during the converge phase of the chef run. The surrounding code is executed immediately.


-- 
Daniel DeLeo
 



Archive powered by MHonArc 2.6.16.

§