Looping in Puppet

github logo ・1 min read

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

twitter logo DISCUSS
Classic DEV Post from Jan 23

Lost potential of personal computing

Do you remember when computers were fun to explore?

Sree Lasya Vallabhaneni profile image

DEV is where senior developers are built

Sign up (for free)