DEV Community

Sree Lasya Vallabhaneni
Sree Lasya Vallabhaneni

Posted on

Looping in Puppet

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)

Collapse
 
raphink profile image
Raphaël Pinson

Did the end of the article get truncated?