Search code examples
unixprovisioningchef-infravagrant

Local personalisations for Vagrant boxes?


As a developer, if I want each and every vagrant box I build from any repository to include my customisations, how would I achieve that?

For example, I have my own vim config, my own tmux config, my own git config, plus there are certain command-line tools I expect on every unix environment I use, such as the aforementioned plus curl and ack.

I would hope Vagrant would include the ability to customise local versions of checked-out box configurations, but I couldn't find out how to do it.

I can't use the normal Vagrantfile because this comes from the repository. I can't create a custom base box, because the Vagrantfile that is checkout out from the repository specifies which base box it wants to use.

Currently the best way I've come up with is to create a repository containing my configs and set it up when I first log in to a newly built Vagrant box by installing all the software I expect through apt-get and then importing my configuration files, but clearly this is frustrating if I'm building a lot of boxes.

Does anyone know how I can automate this?


Solution

  • There are actually a bunch of Vagrantfiles, loaded in a specific order.

    The one that's meant for personal/local customisations is located in ~/.vagrant.d/, so any changes you want applied to all boxes build by you, just put them in a ~/.vagrant.d/Vagrantfile.

    Voila!