Let's say I have two cookbooks, Foo and Bar. In cookbook Foo, attributes/default.rb contains the following:
default[:test] = [{:baz => 'A', :qux => 'B'}]
In cookbook B, I'd like to expand that array with another object (i.e. merge the two arrays): {:baz => 'C', :qux => 'D'}
, ideally from within a recipe.
I tried to put the following Bar's recipe, or the attributes file:
default[:test] = [{:baz => 'C', :qux => 'D'}]
Expecting the two to get merged and result in:
node[:test] == [{:baz => 'A', :qux => 'B'}, {:baz => 'C', :qux => 'D'}]
But that is not what happens. Instead, only one of the two objects is contained in the array during a Chef-Solo run. I also tried with default.override
and default.set
with the same results. How can I merge the two arrays?
Thanks.