On Dec 7, 7:55 am, Alexander Swen <[email protected]> wrote:
> hi,
>
> I'm a bit confused while passing a parameter to a definition i've
> made.
> My aim is to create a htpasswd file on my icinga server, using the
> hashed passwords from my userlist. I only want to execute this on a
> icinga server, not all my servers.
>
> this is what i've got:
>
> 1st my node definition:
> node default {
>  class['users::userlist']:
>    stage => main;}
>
> node nl14s0008-vm7 inherits default {
>  include monitor}
>
> it includes this class:
> class monitor($marktgroep='healthcare',$functie='Monitor en grapher')
> {
>   class {
>     ['linuxlogo','motd']:
>       stage => main;
>     ['users::beheerserver']:
>       functie => $functie,        #### this is where I expect to pass
> my param
>       stage   => main;
>     "icinga::server":
>       stage => main;
>     "iptables":
>       internal_if => 'eth0',
>       stage => main;
>   }
>
> }
>
> here my definition, notice the functie='' at the end:
>
> define users::account($realname, $password, $uid, $othergroups=[],
> $gid, $key='', $keytype='ssh-rsa', $name, $ensure=present, shell='/bin/
> bash', managehome='true', allowdupe='false', homeprefix='/home',
> $functie='' ) {
>
> <SNAP> (this contains a lot of (for this matter) irrelevant text)
>
>       if $functie == 'Monitor en grapher' {
>         icinga::htpasswd {
>           "$name":
>             name     => $name,
>             password => $password,
>             ensure   => $ensure;
>         }
>
> In the icinga class I define a file
>
> class users::beheerserver($functie='') {
>   Users::Account <| (othergroups == 'pep' or othergroups ==
> 'healthcare') |>
>
> }
>
> oh, and I include this:
> class users::userlist {
>   include users::groups
>   @users::account {
>     "root":
>       uid      => "0",
>       gid      => "0",
>       realname => "root",
>       othergroups => ['healthcare','beheerders'],
>       password => 'Here I've got a hashed passwd that should work in
> my htpasswd as well as my shadow file';
>
> }
>
> however: the icinga::htpasswd thing never get's executed. why?


You make inclusion of the icinga::htpasswd resource conditional on the
$functie parameter passed to your users::account definition.  The only
place you show that definition being instantiated is in class
users::userlist, where no explicit value for that parameter is
specified.  Instances created there therefore take the definition's
default value for that parameter, ''.  The $functie parameter to class
users::beheerserver is irrelevant for this purpose.

You SHOULD redesign this so that users::account instances are
initially created with the correct parameters.  That is by far the
best solution.  It will save you pain and extra work later, I
guarantee.

Nevertheless, if it's more important just to make it work right now,
then class users::beheerserver can override the $functie property of
the users::account instances it collects, like so:

Users::Account <| (othergroups == 'pep' or othergroups ==
'healthcare') |> {
  functie => "${functie}"
}

I reiterate that if you choose to do that -- other than as a temporary
stopgap -- then you will eventually regret it.


John

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to