[chef] Re: ruby syntax issue or may be chef command


Chronological Thread 
  • From: Douglas Thrift < >
  • To:
  • Subject: [chef] Re: ruby syntax issue or may be chef command
  • Date: Wed, 30 Oct 2013 11:03:03 -0700

That doesn't work because the ruby_block's block doesn't execute until
converge time and the loop you have there that is outside of the
ruby_block runs at compile time.

Douglas William Thrift
< >
<http://douglasthrift.net/>

On 10/30/2013 1:47 AM, Manoj Thakkar wrote:
> 
>  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  please advise
> 
> Here is the code i am writing:
> 
> 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
> 
> 
> properties file data :
> 
> pbldejksu300:'acc1','acc2'
> pdevecsas300:'acc1','acc2'
> 
> *logs :* 
> 
> Cookbook Trace:
> ---------------
>   /var/chef/cache/cookbooks/base_tomcat/recipes/new.rb:26:in `block in
> from_file'
>   /var/chef/cache/cookbooks/base_tomcat/recipes/new.rb:9:in `from_file'
> 
> 
> 
> [2013-10-30T01:45:07-07:00] ERROR: Running exception handlers
> [2013-10-30T01:45:07-07:00] FATAL: Saving node information to
> /var/chef/cache/failed-run-data.json
> [2013-10-30T01:45:07-07:00] ERROR: Exception handlers complete
> Chef Client failed. 0 resources updated
> [2013-10-30T01:45:07-07:00] FATAL: Stacktrace dumped to
> /var/chef/cache/chef-stacktrace.out
> [2013-10-30T01:45:07-07:00] FATAL: NoMethodError: undefined method
> `each' for "\"acc1\",\"acc2\" ":String



Archive powered by MHonArc 2.6.16.

§