Skip to content

Instantly share code, notes, and snippets.

@parente
Last active August 29, 2015 13:57
Show Gist options
  • Select an option

  • Save parente/9686438 to your computer and use it in GitHub Desktop.

Select an option

Save parente/9686438 to your computer and use it in GitHub Desktop.
Multi-VM Vagrantfile template w/ Docker exposed
# -*- mode: ruby -*-
# vi: set ft=ruby :
$script = <<SCRIPT
sudo apt-get -y install linux-image-extra-$(uname -r)
sudo sh -c "wget -qO- https://get.docker.io/gpg | apt-key add -"
sudo sh -c "echo deb http://get.docker.io/ubuntu docker main\ > /etc/apt/sources.list.d/docker.list"
sudo apt-get update
sudo apt-get -y install lxc-docker
sudo usermod -a -G docker vagrant
sudo service docker stop
sudo sed -i /etc/init/docker.conf -e 's#DOCKER_OPTS=#DOCKER_OPTS="-H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock"#'
sudo service docker start
echo "vagrant:vagrant"|chpasswd
SCRIPT
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provision :shell, :inline => $script
config.vm.box = "https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box"
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
vb.customize ["modifyvm", :id, "--memory", "4096"]
vb.customize ["modifyvm", :id, "--cpus", "4"]
end
# master for development
config.vm.define "master" do |box|
box.vm.network "private_network", ip: "192.168.11.10"
box.vm.synced_folder ".", "/Users/parente/projects"
box.vm.hostname = "master"
end
# upgrade sandbox for development
config.vm.define "upgrade" do |box|
box.vm.network "private_network", ip: "192.168.11.11"
box.vm.hostname = "upgrade"
end
# public
config.vm.define "public" do |box|
box.vm.network "private_network", ip: "192.168.11.12"
box.vm.hostname = "public"
for i in 49500..49600
box.vm.network "forwarded_port", guest: i, host: i
end
end
# clean test environment
config.vm.define "test" do |box|
box.vm.network "private_network", ip: "192.168.11.13"
box.vm.hostname = "test"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment