[chef] error parsing array in chef recipe


Chronological Thread 
  • From: Manoj Thakkar < >
  • To: " " < >
  • Subject: [chef] error parsing array in chef recipe
  • Date: Sat, 16 Nov 2013 11:05:28 -0800

What i am trying to do ? ---- read a property file and get a comma delimited value, run a for loop on the values retrieved and do some resource action.

these are the 2 issues i face :
   1.  The last value in my for loop gets an extra ^J character.
   2.  I get another error for my bash resource 

i have been trying to debug it for hours now, 


Please help

my order-rest.properties is like this :

pbldejksu300:acc1,acc2
pbldejksu301:acc1,acc2


chef recipe :

cookbook_file "/local_app/#{node[:tcat][:war_name]}.properties" do
  source "#{node[:tcat][:war_name]}.properties"
  mode 0777
  owner "deploy"
  group "deploy"
end

Chef::Log.info " host name is #{node['hostname']} "
host=node['hostname']
puts " hostname is #{host}"
output=Array.new
output=`cat /local_app/order-rest.properties | grep -i "#{host}" | cut -d":" -f2 `
output.chomp
node.set['data']['acc_deploy']=output
Chef::Log.info "Found correct value #{output} "
Chef::Log.info "Found correct value again #{node['acc_deploy']} "

node[:data][:acc_deploy].each do |data|
base=data.to_s
data.chomp
Chef::Log.info "Found correct value wow  #{data} "
base="install_tcat_" + data

Chef::Log.info "Found correct value wow  #{base} "
directory "/local_app/test/#{data}" do
  owner "deploy"
  group "deploy"
  mode 0755
  action :create
 notifies :run, "bash[inst_tcat_data]", :immediately
end



Error logs :  

~]$ ls /local_app/test/
acc1  acc2?     ---  the acc2 here got the extra ? i am not sure why and where from , the array was parsed correctly i believe

also  i get this error in the bash resource .... 

[2013-11-15T18:09:39-08:00] INFO: Found correct value wow  install_tcat_'acc2'
 
[2013-11-15T18:09:39-08:00] INFO: Found correct value  in the loop now  'acc2'

Converging 5 resources
[2013-11-15T18:09:39-08:00] INFO: Running queued delayed notifications before re-raising exception
[2013-11-15T18:09:39-08:00] ERROR: Running exception handlers
[2013-11-15T18:09:39-08:00] FATAL: Saving node information to /var/chef/cache/failed-run-data.json
[2013-11-15T18:09:39-08:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated
[2013-11-15T18:09:39-08:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2013-11-15T18:09:39-08:00] FATAL: ArgumentError: You must have a string like resource_type[name]!



  • [chef] error parsing array in chef recipe, Manoj Thakkar, 11/16/2013

Archive powered by MHonArc 2.6.16.

§