title: Puppet - iterate over hash
body: <p>We're using puppet 3.8 (unfortunately can't move to puppet 4 yet)</p>
  
  <p>I've got a hash in hiera that looks something like this:</p>
  
  <pre><code>hash_data:
    item1:
      field1:   'some data'
      array_data:
        - data1
        - data2
    item2:
      field1:   'other data'
      array_data:
        - data3
        - data4
  </code></pre>
  
  <p>I've put together a module with code something like:</p>
  
  <pre><code>class processor {
      $data = hiera_hash('hash_data', {})
  
      create_resources(processor::hash_entry, $data)
  }
  
  define processor::hash_entry ($field1, $array_data) {
  #    .. do_something ..
  
  # process array items
      processor::process_array { $array_data : 
          datavar = 'somevalue'
      }
  }
  
  define processor::process_array($element, $datavar) {
      # do something
  }
  </code></pre>
  
  <p>this works fine as long at the array_data fields in the hash all contain unique fields. However, if I need to put non-unique data something like:</p>
  
  <pre><code>hash_data:
    item1:
      field1:   'some data'
      array_data:
        - data1
        - data2
    item2:
      field1:   'other data'
      array_data:
        - data3
        - data2                  ( **non-unique value **)
  </code></pre>
  
  <p>then we hit a duplicate resource. Can anyone suggest how I could process that hash?</p>
  
  <p>Thanks</p>