Karen Almog
2013-Apr-04 14:52 UTC
[Puppet Users] using if statements inside custom resource
Hi, 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: *$app_users = [ at1,et1,at2,et2 ]* The users.pp manifest then reads the array to create the users: * define appuser { user { $name: ensure => ''present'', comment => "Application User - $name", gid => ''app'', home => "/apps/$app/$name", shell => ''/usr/bin/bash'', } } appuser { $app_users: } * 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. Adding the following if statement inside the resource issues an error: * if $name =~ /^(et|ep)/ { $app = "echos" notice(''app is $app'') }* *Syntax error at ''if''; expected ''}'' at .../users.pp:9 * I read somewhere that you cannot place an if statement inside a resource, and in that case, what are my options? We''re using puppet master version 2.7.19 (Puppet Enterprise 2.7.0). Thanks in advance! -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.