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


Chronological Thread 
  • From: Manoj Thakkar < >
  • To: " " < >
  • Subject: [chef] Re: Re: ruby syntax issue or may be chef command
  • Date: Wed, 30 Oct 2013 11:21:59 -0700

Thanks Doug, 

but i see the value of the node attribute though in the logs ,


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

looks like its getting the value but not treating it as an array of strings or something.

Thanks
Manoj



On Wed, Oct 30, 2013 at 11:03 AM, Douglas Thrift < " target="_blank"> > wrote:
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.

§