How to add a file to the home directories of all existing and future users

puppet

I'm starting to use puppet to manage a couple of servers and I'm not sure how to achieve the following.

I've got a users module which I use to create common users across all servers. I've got a git module which I use to install git and set up a system-wide config in /etc/gitconfig. What I'd like to do is:

  1. On servers which are configured to install git (not all of them), go and drop a (templated) .gitconfig into the home directories of all existing users. And obviously manage this for changes to the template.
  2. Add the .gitconfig for all future users. But I don't feel this belongs in the users module – I think it belongs in the git module. It feels like I want to know when any user has been added (not just a given instance of user), and then be able to access the parameters of that user creation (e.g. home directory, real name and username).

Essentially, part 2 would be easy if I just deployed a templated .gitconfig to all users created by the users module. But I don't really want users to have a .gitconfig file if git isn't installed on the system. So what I'm really trying to say is "for all managed users on this system, if git is installed, manage a .gitconfig file".

Thanks!

Best Answer

Yo will need to use two procedures , first for already created accounts :

http://www.cyberciti.biz/tips/linux-unix-shell-batch-copy.html

and another one for future users :

http://linuxers.org/howto/how-set-default-content-new-users-home-directory-using-etcskel

Related Topic