title: loop, if else over hiera hash in erb template
body: <p>I am almost done with my freeradius puppet module. I am facing now a problem how to loop over hash keys in an ERB template. I am using radius  for 802.1x to authenticate users. If a user is a member of a specific LDAP group, radius will assign him the vlan associated with this group and so on. This is my current configuration:</p>
  
  <p><strong><code>/etc/freeradius/sites-available/inner-tunnel</code></strong></p>
  
  <pre><code>....
  ....
  ....
  ldap
  if (LDAP-Group == vlan_101) {
      update reply {
          Tunnel-Type = VLAN
          Tunnel-Medium-Type = IEEE-802
          Tunnel-Private-Group-ID = 101
      }
  }
  elsif (LDAP-Group == vlan_102) {
      update reply {
          Tunnel-Type = VLAN
          Tunnel-Medium-Type = IEEE-802
          Tunnel-Private-Group-ID = 102
      }
  }
  elsif (LDAP-Group == vlan_103) {
      update reply {
          Tunnel-Type = VLAN
          Tunnel-Medium-Type = IEEE-802
          Tunnel-Private-Group-ID = 103
      }
  }
  else {
      update reply {
          Tunnel-Type = VLAN
          Tunnel-Medium-Type = IEEE-802
          Tunnel-Private-Group-ID = 110
      }
  }
    ....
    ....
    ....
  </code></pre>
  
  <p>I would like to create this file via ERB template.</p>
  
  <p><strong>common.yaml</strong></p>
  
  <pre><code>test_freeradius::tunnel:
      'vlan_101':
          vlan: '101'
      'vlan_102':
          vlan: '102'
      'vlan_103':
          vlan: '103'
      'vlan_110':
          vlan: '110'
  </code></pre>
  
  <p>and I am using the following define.</p>
  
  <p><strong>define test_freeradius::tunnel</strong></p>
  
  <pre><code>define test_freeradius::tunnel (
  
    $vlan,
  
  ){
  
    include test_freeradius::service
  
    file { '/etc/freeradius/sites-available/inner-tunnel' :
      ensure  =&gt; 'file',
      owner   =&gt; 'root',
      group   =&gt; 'freerad',
      mode    =&gt; '0644',
      content =&gt; template("${module_name}/tunnel.erb"),
      require =&gt; Class['test_freeradius::install'],
      notify  =&gt; Service['freeradius'],
    } 
  }
  </code></pre>
  
  <p>and calling it now in init.pp</p>
  
  <p><strong>init.pp</strong></p>
  
  <pre><code>....
  ....
  $groups = hiera('test_freeradius::tunnel')
  create_resources(test_freeradius::tunnel, $groups)
  ....
  ....
  </code></pre>
  
  <p>Is it possible to create the inner-tunnel file with ERB template, how could I do it? Or should I just use it as a simple file without hiera and make changes within the file?</p>