Hi,
I'd like to set up vagrant for a couple of projects and am wondering what the best practices are regardings managing both the vagrant files and the code repos of a project. Ideally I'd like a user to be able to set up his development environment by:
- cloning a git repo containing the vagrant config
- run vagrant
The outcome should be:
- the vagrant vm able to run the project (maybe even running the server already)
- a code folder containing the project code that the devs can point their favourite editor to
Now, having experimented with vagrant a bit, I see the following possibilites
Vagrant in code repo:
I can simply add the vagrant config (VagrantFile and chef-repo as it'll use chef-solo provisioning) to the source repository of the project. The folder containing the VagrantFile thus also contains the sources of the application and editors can simply point their editors to the code repo, which is synced with /vagrant within the virtual box.
For small simple projects with a single code repo it seems like the way to go.
Separate vagrant repo + one or many code repos:
However, what if the project has multiple code repos (multiple application servers, gem dependencies used accross multiple projects)?
I could also create a separate repo for the vagrant config. The source code for the project would have to be cloned by the vagrant provisioner or a shell script. I can add shared folders for different the source code repos.
However, I'd like my cloned vagrant repo to contain all code repo folders (those should not be outside that folder). We could probably use git submodules here, but then some tools don't work very well with submgodules and I'm not sure if developers can just use "git pull" to pull changes, or if they have to use "git submodules update". It might be a nice way to express which version of the vagrant config runs with which version of the code repos, though.
Alternatively, I could also simply check out into subfolders of /vagrant, and use .gitignore file for the subfolders containing the source code repos (or use a subfolder code with .gitignore set to **/*) Not sure if this is cleaner though.
What do you think? How do you manage your repos? What is best practice? Any scenario where the approaches above might not work (ex. trying a new rails version on code repo branch)?
Thanks for your feedback and suggestions!
Nils