title: Puppet: if statment inside a custom resource
body: <p>I am trying to write a manifest that iterates through an array to create and maintain application users.
  The list of users is passed to the manifest from init.pp in the following fashion:</p>
  
  <pre><code>$app_users = [ at1,et1,at2,et2 ]
  </code></pre>
  
  <p>The users.pp manifest then reads the array to create the users:</p>
  
  <pre><code> define appuser {
      user { $name:  
      ensure           =&gt; 'present',
      comment          =&gt; "Application User - $name",
      gid              =&gt; 'app',
      home             =&gt; "/apps/$app/$name",
      shell            =&gt; '/usr/bin/bash',
    }
   }
  
   appuser  { $app_users: }
  </code></pre>
  
  <p>This solution worked very well with another module I wrote, but in this case the home directory path includes a variable, that depends on the user name.</p>
  
  <p>Adding the following if statement inside the resource issues an error:</p>
  
  <pre><code>if $name =~ /^(et|ep)/ {
   $app = "echos"
   notice('app is $app')
   }
  
  Syntax error at 'if'; expected '}' at .../users.pp:9
  </code></pre>
  
  <p>I read somewhere that you cannot place an if statement inside a resource...</p>
  
  <p>In that case, what are my options? I'm experiencing a coding block...</p>
  
  <p>We're using puppet master version 2.7.19 (Puppet Enterprise 2.7.0).</p>