Hi I'd like some help on how to code this in erb in puppet, basically I have
server::actionhost { 'details': servername[ 'felix', 'washington', ], ipa [ '192.168.43.5', '192.168.43.11', ], enviro [ 'prod', 'uat', ], } I now want to print this out to a file with each respective element from each array in one line, i.e the output from the template file in my class should be like:
felix 192.168.43.5 prod washington 192.168.43.11 uat When I attempted this I wrote the following code in my template file:
<% servername.each do |name| -%> <% ipa.each do |ip| -%> <% enviro.each do |env| -%> <%= name %> <%= ip %> <%= env %> <% end -%> <% end -%> <% end -%> but what I get is multiple recursive prints instead of a print from each array and then move to the next array element.
I'm thinking of a for loop but unsure how to get the array length as the argument to the for loop, Would appreciate some guidance on how to accomplish the correct output?
I tried doing something like this but it fails with errors on the puppet run?
<% for id in servername.length %> <%= servername[id] %> <%= ipa[id] %> <%= enviro[id] %> <% end -%> Thanks Dan