title: Function Reference - create_resources in puppet
body: <p>refer <a href="https://docs.puppetlabs.com/references/latest/function.html#createresources" rel="nofollow">https://docs.puppetlabs.com/references/latest/function.html#createresources</a></p>
  
  <pre><code># A hash of user resources:
  $myusers = {
    'nick' =&gt; { uid    =&gt; '1330',
                gid    =&gt; allstaff,
                groups =&gt; ['developers', 'operations', 'release'], },
    'dan'  =&gt; { uid    =&gt; '1308',
                gid    =&gt; allstaff,
                groups =&gt; ['developers', 'prosvc', 'release'], },
  }
  
  create_resources(user, $myusers)
  </code></pre>
  
  <p>Read the explanation for this function <code>create_resources</code>, but not sure what result after <code>create_resources(user, $myusers)</code></p>
  
  <p>Does it create two users <code>nick</code> and <code>dan</code> with nominated uid, gid and groups?</p>
  
  <h3>updates:</h3>
  
  <p>some explanations from web.</p>
  
  <pre><code>Listing 12-79. Hiera lookup of sysadmin hash
  root@puppet-master-hiera-ubuntu:/etc/puppet/data# hiera sysadmins
  {"spencer"=&gt;{"uid"=&gt;1861, "groups"=&gt;"root", "gid"=&gt;300}, "william"=&gt;{"uid"=&gt;11254,
  "groups"=&gt;"root", "gid"=&gt;300}}
  
     Now we can use a function called create_resources() to generate Puppet resources from this hash, as shown in
  
  Listing 12-80. create_resources example
  
  $sysadmins = hiera('sysadmins')
  
  create_resources(user, $sysadmins)
  
      Listing 12-81 shows the output.
  
  Listing 12-81. Applying the create_resources example from Listing 12-80
  
  root@puppet-master-hiera-ubuntu:/etc/puppet# puppet apply create_resources.pp
  Notice: Compiled catalog for puppet-master-hiera-ubuntu.green.gah in environment production in
  0.11 seconds
  Notice: /User[spencer]/ensure: created
  Notice: /User[william]/ensure: created
  Notice: Finished catalog run in 0.32 seconds
  </code></pre>
  
  <p>I can't properly set and prove it in my environment, but above sample gives the answer, it DOES create user accounts with hash in <code>create_resources</code> function.</p>