I have a small problem with my chef cookbook, i'm trying todo a nested loop (loop in loop). I have a array with multiple levels and i would like to loop all levels in a chef template. Right now i'm down at the following:
Template:
<% @countries.each do |country| %>
<% @countries[@country].each do |key, val| %>
<Publication <%= @country @key @val %> />
<% end %>
<% end %>
Attribute:
default['countries']['IE'] = {'57'=>'val2','58'=>'val2','61'=>'val','63'=>'val'}
default['countries']['DE'] = {'110'=>'val2','113'=>'val2','115'=>'val2'}
default['countries']['BE'] = {'134'=>'val2','138'=>'val2','139'=>'val2'}
Recipe:
template "conf.xml" do
action :create
variables ({
:countries => node['countries']
})
end
So first i would like too loop the countries level, then loop each level in that array by using the key and val of the array. I hope someone can help me out with this one.
Best, - Thijs