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 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Dec 7, 7:55 am, Alexander Swen <alex.s...@gmail.com> 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 puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Hi John, thank you for taking the effort to answer my question.> 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.I agree and we already did some redesign work, will continue on this Monday...> > 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}" > }ahhh, now I understand how to pass on a param while realizing! thanks!> > I reiterate that if you choose to do that -- other than as a temporary > stopgap -- then you will eventually regret it. > > Johnregards, Alex -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Dec 9, 5:47 pm, Alexander Swen <alex.s...@gmail.com> wrote:> > 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}" > > } > > ahhh, now I understand how to pass on a param while realizing! > thanks!You are welcome, but it is very important to understand that that syntax does not _pass_ a parameter / property. It _overrides_ an existing property of the already-declared virtual resource (which could as easily be of a native type). The distinction is a bit subtle, but you will run into trouble if you are not mindful of it. Notably, if you override properties when you collect a resource then you can collect it only once; otherwise you can collect it any number of times. John -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.