Hi, there Im looking into the same thing. Did you come up with a decent solution?
Regards Bjørn Dyresen 2009/9/28 Eric Gerlach <egerl...@feds.uwaterloo.ca> > > On Fri, Sep 18, 2009 at 09:08:37AM +0200, Kenneth Holter wrote: > > Hi. > > > > > > I've defined a virtual user "kenneth", and depending on a variable in the > > node definiton I'd like to add the users to different groups. Consider > this > > example: > > > > ###### Code start > > > > node "server.example.com" { > > $server_type = "typeA" > > > > realize User[kenneth] > > > > } > > > > @user {"kenneth": > > ensure => present, > > uid => 1000, > > gid => 1000, > > groups => $server_type ? { > > typeA => "wheel", > > default => undef, > > }, > > > > home => "/home/kenneth", > > shell => "/bin/bash", > > comment => "A comment", > > password => '<something>' > > > > } > > > > ###### Code end > > > > If I add the user to an ordinary class (like "class user_kenneth") > instead > > of defining it as a virtual resource, everything works fine. But when > using > > a virtual definition like this, the variable "server_type" doesn't seem > to > > have any effect on the if statement "groups". Am I doing something wrong, > or > > is this not supposed to work? I'm running version 0.24.4. > > I've been off for over a week, so I just noticed you never got an answer to > this question. The variables are filled out at the time the virtual > resource > is defined, not at the time it's realized. > > You might be able to do something like: > > realize User[kenneth] > > User[kenneth] { > groups => $server_type ? { > typeA => "wheel", > default => undef, > } > } > > to realize it the way you want. Haven't tried anything like that though. > Maybe someone else can comment if it works. > > Cheers, > > -- > Eric Gerlach, Network Administrator > Federation of Students > University of Waterloo > p: (519) 888-4567 x36329 > e: egerl...@feds.uwaterloo.ca > > > > --~--~---------~--~----~------------~-------~--~----~ 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 For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---