I am starting to develop in puppet (ruby) and I have the following problem.
I have the current hash that I want to iterate in a template file.
$database_profile_hash =
{
cpu => {
governor => ondemand
energy_perf_bias => powersave
}
sysctl => {
kernel.sched.min.granularity.ns => 10000000
kernel.sched.wakeup.granularity.ns => 15000000
kernel.msgmnb => 6
}
...
}
And my current template is the following:
<% @database_profile_array.each do |arrayValue| %>
[<%= arrayValue %>]
<% database_profile_hash[arrayValue].each do |key,value| %>
<%= key %> <%= value %>
<% end %>
<% end %>
To iterate the array I am trying to use an array to store all the first level names and then use it to iterate the hash:
$database_profile_array = [cpu,sysctl,...]
But I am not able to make it work and I am looking for an exit like this:
[cpu]
governor=ondemand
energy_perf_bias=powersave
[sysctl]
vm.laptop_mode=5
vm.dirty_writeback_centisecs=1500
kernel.nmi_watchdog=0
What I am doing wrong in the template? There is a way to pass the content of the variable "arrayValue" to iterate the hash?
Thanks a lot in advance...