One thing I find helpful when debugging these sort of issues is pry[1].
If the node you're running chef-client on has the pry gem installed
and available to chef, you can just include
require 'pry'
binding.pry
in your recipe wherever you want to set up a breakpoint -- when
chef-client runs, you get dropped into an irb-like shell at that point
in the code where you can inspect variables like node and run
arbitrary code in the context of the compile phase (or in execute
phase if you invoke pry in a ruby_block). Type 'exit' and the chef
run will continue. You can even do things like update the node
variable to test that some change you might later make in
attributes.rb will work.
It's much more convenient than the debug statement/re-upload
strategy that I was using before.
Carl
[1] GitHub - pry/pry: A runtime developer console and IRB alternative with powerful introspection capabilities.
On Thu, Dec 6, 2012 at 11:53 PM, Warren Bain Warren@ninefold.com wrote:
Mark,
As a chef n00b I get lots of these. The attribute you are referencing doesn't exist and so node[:sgbase] which is nil doesn't have a method [:branch]. Hence the slightly confusing error.
Wazza
Warren Bain
http://ninefold.com
Australia's cloud
direct: +61 2 8221 7729
mobile: +61 414 867 559
follow: http://twitter.com/thoughtcroft
Mark J Bradakis mark@bradakis.com wrote:
So I get this error:
NoMethodError
undefined method `' for nil:NilClass
Which comes from this line:
627>> revision node[:sgbase][:branch]
Called by a recipe in a file that does this:
"cookbook_versions": {
"cpan": "= 1.0.0",
"apt": "= 1.0.0",
"sgbase": "= 1.0.0",
"branch": "= 1.0.0"
...
sgbase and branch ARE defined - why the NULL error?
mjb.