2013-02-04 01:02:41 -05:00
|
|
|
# -*- mode: ruby -*-
|
|
|
|
# vi: set ft=ruby :
|
|
|
|
|
2013-05-03 18:35:51 -04:00
|
|
|
BOX_NAME = ENV['BOX_NAME'] || "ubuntu"
|
|
|
|
BOX_URI = ENV['BOX_URI'] || "http://files.vagrantup.com/precise64.box"
|
2013-06-02 17:08:41 -04:00
|
|
|
VF_BOX_URI = ENV['BOX_URI'] || "http://files.vagrantup.com/precise64_vmware_fusion.box"
|
2013-05-11 13:27:42 -04:00
|
|
|
AWS_REGION = ENV['AWS_REGION'] || "us-east-1"
|
|
|
|
AWS_AMI = ENV['AWS_AMI'] || "ami-d0f89fb9"
|
2013-06-07 15:56:39 -04:00
|
|
|
FORWARD_DOCKER_PORTS = ENV['FORWARD_DOCKER_PORTS']
|
2013-04-23 12:44:09 -04:00
|
|
|
|
|
|
|
Vagrant::Config.run do |config|
|
|
|
|
# Setup virtual machine box. This VM configuration code is always executed.
|
|
|
|
config.vm.box = BOX_NAME
|
|
|
|
config.vm.box_url = BOX_URI
|
2013-05-08 22:36:06 -04:00
|
|
|
|
2013-09-25 16:57:04 -04:00
|
|
|
config.ssh.forward_agent = true
|
|
|
|
|
2013-09-04 17:38:03 -04:00
|
|
|
# Provision docker and new kernel if deployment was not done.
|
|
|
|
# It is assumed Vagrant can successfully launch the provider instance.
|
2013-05-08 22:36:06 -04:00
|
|
|
if Dir.glob("#{File.dirname(__FILE__)}/.vagrant/machines/default/*/id").empty?
|
|
|
|
# Add lxc-docker package
|
2013-09-03 20:14:49 -04:00
|
|
|
pkg_cmd = "wget -q -O - https://get.docker.io/gpg | apt-key add -;" \
|
2013-09-03 11:19:05 -04:00
|
|
|
"echo deb http://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list;" \
|
2013-08-24 11:49:55 -04:00
|
|
|
"apt-get update -qq; apt-get install -q -y --force-yes lxc-docker; "
|
2013-08-21 00:44:58 -04:00
|
|
|
# Add Ubuntu raring backported kernel
|
|
|
|
pkg_cmd << "apt-get update -qq; apt-get install -q -y linux-image-generic-lts-raring; "
|
2013-09-04 17:38:03 -04:00
|
|
|
# Add guest additions if local vbox VM. As virtualbox is the default provider,
|
|
|
|
# it is assumed it won't be explicitly stated.
|
2013-08-18 02:58:04 -04:00
|
|
|
if ENV["VAGRANT_DEFAULT_PROVIDER"].nil? && ARGV.none? { |arg| arg.downcase.start_with?("--provider") }
|
2013-09-04 17:38:03 -04:00
|
|
|
pkg_cmd << "apt-get install -q -y linux-headers-generic-lts-raring dkms; " \
|
2013-05-08 22:36:06 -04:00
|
|
|
"echo 'Downloading VBox Guest Additions...'; " \
|
|
|
|
"wget -q http://dlc.sun.com.edgesuite.net/virtualbox/4.2.12/VBoxGuestAdditions_4.2.12.iso; "
|
|
|
|
# Prepare the VM to add guest additions after reboot
|
|
|
|
pkg_cmd << "echo -e 'mount -o loop,ro /home/vagrant/VBoxGuestAdditions_4.2.12.iso /mnt\n" \
|
|
|
|
"echo yes | /mnt/VBoxLinuxAdditions.run\numount /mnt\n" \
|
|
|
|
"rm /root/guest_additions.sh; ' > /root/guest_additions.sh; " \
|
|
|
|
"chmod 700 /root/guest_additions.sh; " \
|
|
|
|
"sed -i -E 's#^exit 0#[ -x /root/guest_additions.sh ] \\&\\& /root/guest_additions.sh#' /etc/rc.local; " \
|
|
|
|
"echo 'Installation of VBox Guest Additions is proceeding in the background.'; " \
|
|
|
|
"echo '\"vagrant reload\" can be used in about 2 minutes to activate the new guest additions.'; "
|
|
|
|
end
|
2013-10-11 13:00:04 -04:00
|
|
|
# Add vagrant user to the docker group
|
|
|
|
pkg_cmd << "usermod -a -G docker vagrant; "
|
2013-05-08 22:36:06 -04:00
|
|
|
# Activate new kernel
|
|
|
|
pkg_cmd << "shutdown -r +1; "
|
|
|
|
config.vm.provision :shell, :inline => pkg_cmd
|
2013-03-22 01:26:18 -04:00
|
|
|
end
|
2013-03-15 00:22:07 -04:00
|
|
|
end
|
2013-04-19 23:57:50 -04:00
|
|
|
|
2013-05-08 22:36:06 -04:00
|
|
|
|
2013-04-23 12:44:09 -04:00
|
|
|
# Providers were added on Vagrant >= 1.1.0
|
|
|
|
Vagrant::VERSION >= "1.1.0" and Vagrant.configure("2") do |config|
|
2013-04-19 23:57:50 -04:00
|
|
|
config.vm.provider :aws do |aws, override|
|
|
|
|
aws.access_key_id = ENV["AWS_ACCESS_KEY_ID"]
|
|
|
|
aws.secret_access_key = ENV["AWS_SECRET_ACCESS_KEY"]
|
|
|
|
aws.keypair_name = ENV["AWS_KEYPAIR_NAME"]
|
|
|
|
override.ssh.private_key_path = ENV["AWS_SSH_PRIVKEY"]
|
|
|
|
override.ssh.username = "ubuntu"
|
2013-05-11 13:27:42 -04:00
|
|
|
aws.region = AWS_REGION
|
|
|
|
aws.ami = AWS_AMI
|
2013-04-19 23:57:50 -04:00
|
|
|
aws.instance_type = "t1.micro"
|
|
|
|
end
|
|
|
|
|
|
|
|
config.vm.provider :rackspace do |rs|
|
|
|
|
config.ssh.private_key_path = ENV["RS_PRIVATE_KEY"]
|
|
|
|
rs.username = ENV["RS_USERNAME"]
|
|
|
|
rs.api_key = ENV["RS_API_KEY"]
|
|
|
|
rs.public_key_path = ENV["RS_PUBLIC_KEY"]
|
|
|
|
rs.flavor = /512MB/
|
|
|
|
rs.image = /Ubuntu/
|
|
|
|
end
|
|
|
|
|
2013-06-02 17:08:41 -04:00
|
|
|
config.vm.provider :vmware_fusion do |f, override|
|
|
|
|
override.vm.box = BOX_NAME
|
|
|
|
override.vm.box_url = VF_BOX_URI
|
|
|
|
override.vm.synced_folder ".", "/vagrant", disabled: true
|
|
|
|
f.vmx["displayName"] = "docker"
|
|
|
|
end
|
|
|
|
|
2013-04-19 23:57:50 -04:00
|
|
|
config.vm.provider :virtualbox do |vb|
|
2013-04-23 12:44:09 -04:00
|
|
|
config.vm.box = BOX_NAME
|
|
|
|
config.vm.box_url = BOX_URI
|
2013-09-06 00:05:23 -04:00
|
|
|
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
|
|
|
|
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
|
2013-04-19 23:57:50 -04:00
|
|
|
end
|
|
|
|
end
|
2013-06-07 15:56:39 -04:00
|
|
|
|
|
|
|
if !FORWARD_DOCKER_PORTS.nil?
|
2013-08-06 09:21:26 -04:00
|
|
|
Vagrant::VERSION < "1.1.0" and Vagrant::Config.run do |config|
|
|
|
|
(49000..49900).each do |port|
|
|
|
|
config.vm.forward_port port, port
|
2013-06-07 15:56:39 -04:00
|
|
|
end
|
2013-08-06 09:21:26 -04:00
|
|
|
end
|
2013-06-07 15:56:39 -04:00
|
|
|
|
2013-08-06 09:21:26 -04:00
|
|
|
Vagrant::VERSION >= "1.1.0" and Vagrant.configure("2") do |config|
|
|
|
|
(49000..49900).each do |port|
|
|
|
|
config.vm.network :forwarded_port, :host => port, :guest => port
|
2013-06-07 15:56:39 -04:00
|
|
|
end
|
2013-08-06 09:21:26 -04:00
|
|
|
end
|
2013-06-07 15:56:39 -04:00
|
|
|
end
|