Question

We're slowly moving our infrastructure over to chef and building a collection of cookbooks on the way.

One thing I'm not sure about is where node / role / user specific dotfiles should go.

For example, we could use the rbenv cookbook to install rbenv for several users,
User A may not want rdoc documentation so would want a custom .gemrc file.

Where should this go?
We could put the file contents in node / role specific JSON file, or in a data bag but this doesn't feel right.

Is there a way to include the actual file in a way that is not for the general cookbook, but rather for the specific node / user?

Was it helpful?

Solution

The way I've historically dealt with this is by adding a user's Github profile name to their node and downloading their own hosted dotfiles if that attribute is set and a default (organization) set if not.

For instance:

git "/home/user/dotfiles" do
  repository "git@github.com:git_user/dotfiles.git"
  user "user"
  group "user"
end

execute "cp -R /home/user/dotfiles /home/user"

You could also set the repository as a node attribute so that they aren't just limited to their own repo.

The files don't necessarily need to be copied either. Personally, I symlink them, but you need to know a bit of how they're set up ahead of time to make the script robust enough for that to work in a stable way.

OTHER TIPS

You do have another option of using cookbook_file instead.

If you create a cookbook that has everyone's dot files in it, something to the effect:

cookbook_file "billy.vimrc" do
  path "/home/billy/.vimrc"
end

Have everyone have commit rights to the overarching cookbook/repo and push things out via that way. IT's very much a hack, and cleanup (assuming someone left) might be a little annoying, but user management normally is ;).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top