You can set the default values to undef and then the standard user type
will use its defaults (if any).  It usually makes sense to default the
ensure parameter to 'present' though because if it is undef then nothing
will happen:

define site::user (
        $ensure     = 'present',
        $comment = undef,
        $home       = undef,
        $password = undef,
    ) {
    user { $title:
        ensure     => $ensure,
        comment => $comment,
        home       => $home,
        password => $password,
    }
    ...
}

Note that $name and $title are the same thing so you probably shouldn't
specify a value for $name.

  - Keith


On 27 January 2013 00:55, Matthew Pounsett <matt.pouns...@gmail.com> wrote:

> I'm trying to extend the standard 'user' type to add maintenance of some
> of the contents of a user's home directory, and I'm trying to avoid
> creating an entirely new custom type if I can.  The approach I'm taking is
> to create a site::user defined type which in turns calls the standard user
> type.  I'm having a problem figuring out how to manage the optional
> parameters.
>
> The most likely path seems to be something like this (simplified for
> example):
>
> define site::user (
>         $comment,
>         $ensure,
>         $home,
>         $name = $title,
>         $password,
>     ) {
>
>     user { "$title":
>         comment => $comment,
>         ensure => $ensure,
>         home => $home,
>         name => $name,
>         password => $password,
>     }
> }
>
> The problem with this, of course, is that the parameters to site::user
> aren't optional, and I'd like them to be.  I've tried setting their
> defaults to null strings, but I get errors about reassigning variables if I
> do that.
>
> Of course, this would be even better.. but doesn't appear to be a valid
> syntax in puppet:
>
> define site::user ( $**args ) {
>    user { "$title":
>       $args
>    }
> }
>
> This seems to me to be the sort of thing that'd be in a puppet cookbook,
> but google hasn't shown me any useful docs or examples for what I'm trying
> to do.  Does this approach even make sense, or is there a better way?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To post to this group, send email to puppet-users@googlegroups.com.
> To unsubscribe from this group, send email to
> puppet-users+unsubscr...@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.
>
>
>

-- 
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+unsubscr...@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.


Reply via email to