Puppet to manage $HOME dotfiles
Posted Tue, 21 Jul 2009
On SysAdvent
Day 11 I covered the importance of having your own personal environment
carry with you. This includes your rc files like .vimrc, etc.
If you manage users with puppet, here's how to manage it with puppet while falling back to a default skeleton (similar to /etc/skel) directory for users who don't have individual ones:
class user::people {
# ...
define localuser($uid, ...) {
user {
"$name":
uid => $uid,
...;
}
file {
"/home/$name":
ensure => directory,
owner => $name,
group => $gid,
source => [ "puppet:///user/home/$name/",
"puppet:///user/skel/" ];
}
}
localuser {
"jls": uid => 10000;
}
}
Puppet will first search for 'user/home/$name' on it's file server, and sync it
if it exists. If it does not exist, it falls back to 'user/skel'. The benefit
here is that whenever you update the default 'skel' directory, all users who
depend on it will be automatically updated by puppet.
Update: I've since stopped using this method to sync homedirectories. Puppet (at time of writing, 0.25.1) is not smart about how it scans for files to update when recursion is on - puppet walks all files in each homedir, even if they aren't part of the file list to be pushed by puppet. I use the synchome.sh script mentioned in sysadvent 2008 day 11 with a cron job. This cron job is deployed with puppet.