A simple example of how to loop an array of hash maps in a puppet manifest to template
targets => [
{
host => 'example.com',
port => '443',
},
{
host => 'example1.com',
port => '8081',
},
{
host => 'example2.com',
port => '80',
},
]
This part is for looping in the erb template.
<% @targets.each do |variable | -%>
<%= variable['host'] %> <%= variable['port'] %>
<% end -%>
targets is the array of list and variable is the name of the varible you would like to specify
Top comments (1)
Did the end of the article get truncated?