ruby - Chef Template : Using a nested object to generate a configuration file -
i generate config file chef
template. correct syntax achieving in chef 13+
i have databag following sub keys:
"mykey1" : { "param1" : "mysubvalue1", "param2" : "mysubvalue2" }, "mykey2" : { "param1" : "mysubvalue11", "param2" : "mysubvalue22" },
then in recipe use template resource:
template 'mytemplate.erb' ... variables ({ :keys => [mykey1, mykey2] }) end
then in template:
<% @keys.each_pair |name, _object| %> ["#{name}"] param1 = "#{_object.param1}" # work?? <% end %>
what correct way reference param1
, param2
by time data that, it's normal ruby hash object. use _object["param1"]
.
Comments
Post a Comment