Very rough description on how I use Vagrant. Uses some SSH magic to get easy git access to your private repos.
- Use most recent version of vagrant.
- Some tools and plugins:
- vagrant-dns (MacOS only!) starts a local DNS Server, so that you can access your webserver with a domain name (not only an IP). After installation (
vagrant plugin install vagrant-dns
) runvagrant dns --install
to initially setup some system configurations on your system. This will require you to enter your password once. - vagrant-vbguest - When you are using VirtualBox, it's recommended to install this plugin, which helps fighting some VirtualBox update issues.
- vagrant-auto_network - When using many boxes, manually configuring gets tedious. Also it makes it hard to share the same
Vagrantfile
with your coworkers.
- vagrant-dns (MacOS only!) starts a local DNS Server, so that you can access your webserver with a domain name (not only an IP). After installation (
Prepare your local machine to play well with git inside the devbox:
If you don't have already, teach your shell your git names. Edit, or create the file ~/.profile
(or ~/.zprofile
when using zsh) to include:
export GIT_AUTHOR_EMAIL='your mail address'
export GIT_AUTHOR_NAME='Your Name'
export GIT_COMMITTER_EMAIL='your mail address'
export GIT_COMMITTER_NAME='Your Name'
export GIT_EDITOR=/usr/bin/vim
Setup ssh authentication hand-over to your local machine (like it is used when connecting to github or bitbucket), also tell the devbox about your git settings. Edit, or create the file ~/.ssh/config
to include:
Host *
SendEnv GIT_*
For a deeper reference, see our chef cookbooks.
This setup does not require Chef, I just happen to use it and stick with it for some time.
In your Vagrantfile
you should setup "ssh agent forwarding":
Vagrant.configure("2") do |config|
config.ssh.forward_agent = true
end
For a deeper reference, see our packer templates.
Make sure your box can access your git server:
/etc/ssh/sshd_config
should include Acceptenv GIT_*
.
Most projects I'm working on require a distinct setup, sometimes with very special requirement. Thats why I find it most useful to create a box for each project. This box can than easily be shared with your coworkers:
Although these steps are unique to git, probably most other VCS allow a similar setup.
- Create a "devbox" branch within your project's repository:
# Create a new orphan branch, detached from start
git checkout --orphan devbox
# clear the working tree
git rm --cached -r .
# remove all files (if you have hidden files like .rvmrc, you'll want to remove them as well)
rm -Rf ./*
- create your devbox (
vagrant init
) - OR pull in a base repo like devbox-bookshelf (
git pull https://github.com/dotless-de/devbox-bookshelf.git
) and start costuming.
- Other checkouts (eg. for coworkers):
git clone [email protected]/project/repo.git -b devbox your-project-devbox
cd your-project-devbox
- Bring it up:
vagrant up
(or:vagrant up --provider=vmware_fusion
when using VMWare Fusion)
License: CC BY-SA 4.0