Dashes are not valid in symbol names unless you quote them. It’s interpreted as `:acc - deploy`. Just switch to underscores and you’ll be good.
On Tuesday, October 29, 2013 at 1:38 PM, Manoj Thakkar wrote:
> Thanks Andrew,
>
> i pasted the wrong code , i fixed that _ vs "-" thing , but it still did not work ,same error
>
> Chef Client failed. 0 resources updated
> [2013-10-29T13:36:43-07:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
> [2013-10-29T13:36:43-07:00] FATAL: NoMethodError: undefined method `each' for nil:NilClass
> You have mail in /var/spool/mail/deploy
>
>
>
> cookbook_file "/local_app/account-rest.properties" do
> source "account-rest.properties"
> mode 0777
> owner "deploy"
> group "deploy"
> end
> ruby_block "acc-deploy-host" do
> block do
>
> host=`hostname -s`
> node.set[:acc-deploy] = `cat /local_app/account-rest.properties | grep -i "#{host}" | cut -d":" -f2 `
> puts "value is #{node[:acc-deploy]}"
> end
> action :create
> end
> node['acc-deploy'].each do |x|
> puts #x
>
> end
>
>
>
>
> On Tue, Oct 29, 2013 at 1:32 PM, Andrew Gross < "> (mailto: "> )> wrote:
> > In the first case you use a dash node.set[:acc-deploy]
> > In the second case you are using underscore node['acc_deploy'].each
> >
> > Additionally I would recommend standardizing on symbols vs strings
> >
> > Hopefully that works.
> >
> >
> > On Tue, Oct 29, 2013 at 4:27 PM, Manoj Thakkar < "> (mailto: "> )> wrote:
> > > i changed the code to this ,
> > >
> > > still does not work , what is wrong ?
> > >
> > >
> > > cookbook_file "/local_app/account-rest.properties" do
> > > source "account-rest.properties"
> > > mode 0777
> > > owner "deploy"
> > > group "deploy"
> > > end
> > > ruby_block "acc-deploy-host" do
> > > block do
> > >
> > > node.set[:acc-deploy] = `cat /local_app/account-rest.properties | grep -i "#{host}" | cut -d":" -f2 `
> > > puts "value is #{node["acc-deploy"]}"
> > > end
> > > action :create
> > > end
> > > node['acc_deploy'].each do |x|
> > >
> > > puts #x
> > >
> > > end
> > >
> > >
> > > On Tue, Oct 29, 2013 at 1:17 PM, Manoj Thakkar < "> (mailto: "> )> wrote:
> > > > Hey,
> > > >
> > > > i have been trying to fix this for almost 30 minutes now , thought i shall better ask, please looks at the code snippet below, I am not able to access this simple variable what am i doing wrong ? please advise.
> > > >
> > > >
> > > > cookbook_file "/local_app/account-rest.properties" do
> > > > source "account-rest.properties"
> > > > mode 0777
> > > > owner "deploy"
> > > > group "deploy"
> > > > end
> > > > ruby_block "acc-deploy-host" do
> > > > block do
> > > > node.default["acc-deploy"] = `cat /local_app/account-rest.properties | grep -i "#{host}" | cut -d":" -f2 `
> > > > puts "value is #{node["acc-deploy"]}"
> > > > end
> > > > action :create
> > > > end
> > > > node[:acc_deploy].each do |x| ----- this does not work
> > > > puts #x
> > > >
> > > > end
Archive powered by MHonArc 2.6.16.