title: How to Create Same resource Twice in Puppet
body: <p>My requirement is to do some repetitive file configuration stuff using a loop, Something like following,</p>
  
  <pre><code>$no_of_managers = 2
  $array = ['One','two','Three']
  
  
  define loop() {
  
  notice("Configuring The Manager Nodes!!")
  
  if ($name == $no_of_managers+1) {
      notice("Loop Iteration Finished!!!")
    }
    else
    {
      notice("Iteration Number : $name \n")
  
      # Doing All Stuff Here 
  
  resource {$array:}
  
      $next = $name + 1
      loop { $next: }
   }
   }
  
  loop { "1":}
  
  define resource () {
  # Doing my other Stuff
  notice ("The Parsed value Name : ${name}\n")
  
  }
  </code></pre>
  
  <p>Now when The second iteration is running the following error occurs,</p>
  
  <pre><code>Error: Duplicate declaration: Resource[One] is already declared in file 
  </code></pre>
  
  <p>How can I overcome this, What I'm doing is a cluster setup. Is there a workaround to do this, I'm a newbie for puppet so Your kind guidance highly appreciated.</p>
  
  <p>The Use Case : </p>
  
  <p>I'm trying to setup a cluster which have multiple Manager/Worker nodes, So using this script the user has the privilege to select how many manager nodes he needs. So the first loop is for that to copy necessary files and create required number of nodes.</p>
  
  <p>The second loop is there to push all .erb templates. Because each Node has slightly different configs the .erb files have there own logic inside them.</p>
  
  <p>So after each Iteration I want to push the .erb templates to the respective node.</p>