[chef] Updating attributes in 0.7.6


Chronological Thread 
  • From: Caleb Tennis < >
  • To:
  • Subject: [chef] Updating attributes in 0.7.6
  • Date: Sat, 8 Aug 2009 14:00:54 -0400

When I updated to chef 0.7.6 this morning, I had an issue with my attributes (as noted in CHEF-473), causing this error:

/var/chef/cache/cookbooks/portage/definitions/keyword.rb:11:in `+': can't convert Chef::Node::Attribute into String (TypeError) 

This was because I had attribute code that looked like this:

cluster = Mash.new unless attribute?("cluster") 
cluster[:ruby_version] ||= "1.8.7_p74" 

This worked before 0.7.6, but with the new code in 0.7.6, a new attribute is no longer initially nil, but an instance of Chef::Node::Attribute.  Thus, this value wasn't being set properly.

The fix is to use the normal chef nomenclature..either the new, or the old:

cluster[:ruby_version] = "1.8.7_p74" unless cluster.has_key? :ruby_version

or

set_unless[:cluster][:ruby_version] = "1.8.7_p74"

I'm documenting this here in case anyone else runs into the issue, as fixing the code in chef itself is non-trivial.

Thanks,
Caleb



Archive powered by MHonArc 2.6.16.

§