title: Puppet: Handling multiple resource attributes in generic way
body: <p>For resources where only one or two attributes are changing, i can use array and hashes respectively. For example, if i have to create files in different directories, i can store the file names and respective paths in a hash and apply them by iterating over the hash. In case if i have more than two attributes that are different, how do i store and iterate over those attributes?</p>
  
  <p>For example, i am trying to create Active Directory groups and i have five attributes and all are different for each group as shown below:</p>
  
  <pre><code> Group_Name      Display Name               Path                     Description            GroupCategory
  "My Support"      "Support"    "OU=Groups,OU=DEF,DC=xyz,DC=Com"   "Some decription"           Security
  "Prod DBA"          "DBA"      "OU=Groups,OU=XYZ,DC=xyz,DC=Com"   "Different description"   Distribution
  ...
  ...
  </code></pre>
  
  <p>UPDATE: Based on the suggestion, here's the code:</p>
  
  <pre><code>[root@myhost] cat params.pp
  $ad_groups = {
      'Group_Prod' =&gt; {
          path        =&gt; 'OU=Groups,OU=PROD,DC=TEST,DC=COM',
          displayname =&gt; 'Prod Support',
          description =&gt; 'Prod Support',
      },
  
      'Group_App' =&gt; {
          path        =&gt; 'OU=Groups,OU=APP,DC=TEST,DC=COM',
          displayname =&gt; 'App Support',
          description =&gt; 'App Support',
      },
  }
  
  $ad_groups_defaults = {
      'ensure'        =&gt; present,
      'groupscope'    =&gt; 'Global',
      'groupcategory' =&gt; 'Security',
  },
  
  
  [root@myhost] cat create_groups.pp
  class infra::ad::create_groups (
      $ad_groups = $infra::params::ad_groups,
      $ad_groups_defaults = $infra::params::ad_groups_defaults,
  ) inherits infra::params {
      create_resources(windows_ad::group,$ad_groups,$ad_groups_defaults)
  }
  </code></pre>
  
  <p>Now when i try running it, i am getting the following error:</p>
  
  <pre><code>Could not retrieve catalog from remote server: Error 500 on SERVER: "message":"Server Error: Evaluation Error: Error while evaluating a Resource Statement, Windows_ad::Group[Group_Prod]: default expression for $groupname tries to illegally access not yet evaluated $groupname at /etc/puppetlabs/code/environments/production/modules/infra/manifests/ad/create_groups.pp:5 on node puppet.test.com","issue_kind":"RUNTIME_ERROR"}
  </code></pre>
  
  <p>Now if i also add <code>groupname</code> attribute in each hash block, the error is resolved. What i want to know is that if my group names are same as the hash keys (in this case, <code>Group_Prod</code> and <code>Group_App</code>), then can i somehow use those hash keys itself as <code>groupname</code> without adding <code>groupname</code> attribute in each hash block?</p>