Hi,
I believe it could be this way:
define ssh_user($passwd, $key) {
user { $name:
ensure => present,
managehome => true,
password = $passwd ? {
/\w+/ => $passwd,
default => undef,
}
}
I think you should also double check the class with a define inside.
-frederiko
On Sat, Sep 21, 2013 at 3:42 PM, mark bradley <[email protected]> wrote:
> Hi,
>
> Yet another newbie question .. I'd appreciate any good references, too!
>
> I'm creating a class for managing users, and defining "my_user" as a
> convenience function that I've seen in many patterns. I'd like it to manage
> passwords if one is supplied to the function.
>
> class users::virtual {
> define ssh_user($passwd, $key) {
> user { $name:
> ensure => present,
> managehome => true,
> if $passwd != '' {
> password = $passwd
> }
> }
>
> # more code here
> }
>
>
> I get an syntax error on the "if" statement when I run the agent:
> Error: Could not retrieve catalog from remote server: Error 400 on SERVER:
> Syntax error at 'passwd'; expected '}' at <FILE>.pp:17 on node <FQDN>
>
> Thinking it was a scoping error I've tried various combinations to
> qualify the "passwd" parameter but nothing seems to have helped.
>
> Any guidance would be appreciated.
>
> Mark
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/puppet-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.