Problem trying to override attributes for a node

Hello all,

I must say that normally all our configuration remains in role and
environment files but for a temporally solution.

We have several fronts that normally use a backend all of them, but this
time we need to override this and every frontend must attack with just one
server on the backend.

So I wrote this json (that I though could work, but I have a strange
problem) that returns an strange error in knife:

staging-1.json

{
“name”:“staging-1.public-staging”,
“override”:
{
“nginx”:
{
“upstreams”:
{
“apache-front”:
{
“staging-front-1.staging.local:8080”:
{
“weight”:1
}
}
}
}
}
}

And the error returned by knife is this one:

knife node from file nodes/staging-ws-2.json -VV
/home/antonio/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/chef-11.6.2/lib/chef/node.rb:429:in
json_create': undefined methodeach’ for nil:NilClass (NoMethodError)
from
/home/antonio/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/chef-11.6.2/lib/chef/knife/core/object_loader.rb:92:in
object_from_file' from /home/antonio/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/chef-11.6.2/lib/chef/knife/core/object_loader.rb:42:inload_from’
from
/home/antonio/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/chef-11.6.2/lib/chef/knife/node_from_file.rb:38:in
run' from /home/antonio/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/chef-11.6.2/lib/chef/knife.rb:466:inrun_with_pretty_exceptions’
from
/home/antonio/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/chef-11.6.2/lib/chef/knife.rb:173:in
run' from /home/antonio/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/chef-11.6.2/lib/chef/application/knife.rb:123:inrun’
from
/home/antonio/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/chef-11.6.2/bin/knife:25:in
<top (required)>' from /home/antonio/.rbenv/versions/1.9.3-p448/bin/knife:23:inload’
from /home/antonio/.rbenv/versions/1.9.3-p448/bin/knife:23:in `’

Hope someone can help me, I’m pretty lost. Thanks in advance.

Antonio

After look at the ruby code it seems that I made a mistake not including a
run_list or recipes.

Just adding at the bottom fixed the problem. Now the machine provisions
without issues overriding that value.

“recipes”: [],
“run_list”: []
}

Anytime, thanks!

---------- Forwarded message ----------
From: Antonio Fernández Vara antoniofernandezvara@gmail.com
Date: Thu, Jan 16, 2014 at 10:27 AM
Subject: Problem trying to override attributes for a node
To: chef@lists.opscode.com

Hello all,

I must say that normally all our configuration remains in role and
environment files but for a temporally solution.

We have several fronts that normally use a backend all of them, but this
time we need to override this and every frontend must attack with just one
server on the backend.

So I wrote this json (that I though could work, but I have a strange
problem) that returns an strange error in knife:

staging-1.json

{
“name”:“staging-1.public-staging”,
“override”:
{
“nginx”:
{
“upstreams”:
{
“apache-front”:
{
“staging-front-1.staging.local:8080”:
{
“weight”:1
}
}
}
}
}
}

And the error returned by knife is this one:

knife node from file nodes/staging-ws-2.json -VV
/home/antonio/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/chef-11.6.2/lib/chef/node.rb:429:in
json_create': undefined methodeach’ for nil:NilClass (NoMethodError)
from
/home/antonio/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/chef-11.6.2/lib/chef/knife/core/object_loader.rb:92:in
object_from_file' from /home/antonio/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/chef-11.6.2/lib/chef/knife/core/object_loader.rb:42:inload_from’
from
/home/antonio/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/chef-11.6.2/lib/chef/knife/node_from_file.rb:38:in
run' from /home/antonio/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/chef-11.6.2/lib/chef/knife.rb:466:inrun_with_pretty_exceptions’
from
/home/antonio/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/chef-11.6.2/lib/chef/knife.rb:173:in
run' from /home/antonio/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/chef-11.6.2/lib/chef/application/knife.rb:123:inrun’
from
/home/antonio/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/chef-11.6.2/bin/knife:25:in
<top (required)>' from /home/antonio/.rbenv/versions/1.9.3-p448/bin/knife:23:inload’
from /home/antonio/.rbenv/versions/1.9.3-p448/bin/knife:23:in `’

Hope someone can help me, I’m pretty lost. Thanks in advance.

Antonio