On Sep 8, 3:58 am, Bernd Adamowicz <bernd.adamow...@esailors.de> wrote: > Hi all, > > is there a way to avoid changing the state (present/absent) of a user? In my > case I just want to do a kind of 'check' if the user is present. If so, I > will do some file-resource stuff on him. If not, nothing should be done at > all. > > Example: > > # create the user resource > user { 'someuser': > ... > > } > > # copy file if user exists > # do nothing if not > file { "/home/someuser/.bashrc": > require => "someuser", > ... > > } > > Obviously I cannot use 'ensure => present|absent' for the user, since this > would change its state. And I'm not sure if it's OK just to omit the 'ensure' > attribute. Any ideas?
You could write a custom fact that extracts all the system user names (or all the names of /home subdirectories, or ...) and use that to drive your resource management. You could then do something like the following: # Split the custom fact value into an array $user_array = split($::users_i_care_about, ' ') # Declare the desired resources for each user: my_user_stuff { $user_array: # parameters of the my_user_stuff type, if needed } define my_user_stuff () { # $name is the name of the resource instance file { "/home/${name}/.bashrc": ensure => file, # ... } # other resources for this user as needed ... } That has a bit of code smell to my nose, though, mostly around the fact that you don't know what users are actually supposed to be defined (which in turn is why a custom fact is involved). You could do the same job with a shell script launched periodically by cron, and I think I would prefer that myself. But I would use Puppet to create and manage the crontab entry. 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.