|
| 1 | +# -*- mode: ruby -*- |
| 2 | +# vi: set ft=ruby : |
| 3 | + |
| 4 | +# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! |
| 5 | +VAGRANTFILE_API_VERSION = "2" |
| 6 | + |
| 7 | +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| |
| 8 | + config.vm.box = "precise64" |
| 9 | + config.vm.box_url = "http://files.vagrantup.com/precise64.box" |
| 10 | + config.ssh.forward_agent = true |
| 11 | + |
| 12 | + config.vm.provider :vmware_fusion do |f, override| |
| 13 | + override.vm.box_url = "http://files.vagrantup.com/precise64_vmware_fusion.box" |
| 14 | + f.vmx["displayName"] = "passenger-docker" |
| 15 | + # VMWare Tools is rendered unusable by the kernel upgrade, |
| 16 | + # and there's no easy way to automatically reinstall it, |
| 17 | + # so we use NFS instead of VMWare Shared Folders. |
| 18 | + config.vm.synced_folder ".", "/vagrant", :nfs => true |
| 19 | + end |
| 20 | + |
| 21 | + # Provision docker and new kernel if deployment was not done. |
| 22 | + # It is assumed Vagrant can successfully launch the provider instance. |
| 23 | + if Dir.glob("#{File.dirname(__FILE__)}/.vagrant/machines/default/*/id").empty? |
| 24 | + # Add lxc-docker package |
| 25 | + pkg_cmd = "wget -q -O - https://get.docker.io/gpg | apt-key add -;" \ |
| 26 | + "echo deb http://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list;" \ |
| 27 | + "apt-get update -qq; apt-get install -q -y --force-yes lxc-docker; " |
| 28 | + # Add Ubuntu raring backported kernel |
| 29 | + pkg_cmd << "apt-get update -qq; apt-get install -q -y linux-image-generic-lts-raring; " |
| 30 | + # Add guest additions if local vbox VM. As virtualbox is the default provider, |
| 31 | + # it is assumed it won't be explicitly stated. |
| 32 | + if ENV["VAGRANT_DEFAULT_PROVIDER"].nil? && ARGV.none? { |arg| arg.downcase.start_with?("--provider") } |
| 33 | + pkg_cmd << "apt-get install -q -y linux-headers-generic-lts-raring dkms; " \ |
| 34 | + "echo 'Downloading VBox Guest Additions...'; " \ |
| 35 | + "wget -q http://dlc.sun.com.edgesuite.net/virtualbox/4.2.12/VBoxGuestAdditions_4.2.12.iso; " |
| 36 | + # Prepare the VM to add guest additions after reboot |
| 37 | + pkg_cmd << "echo -e 'mount -o loop,ro /home/vagrant/VBoxGuestAdditions_4.2.12.iso /mnt\n" \ |
| 38 | + "echo yes | /mnt/VBoxLinuxAdditions.run\numount /mnt\n" \ |
| 39 | + "rm /root/guest_additions.sh; ' > /root/guest_additions.sh; " \ |
| 40 | + "chmod 700 /root/guest_additions.sh; " \ |
| 41 | + "sed -i -E 's#^exit 0#[ -x /root/guest_additions.sh ] \\&\\& /root/guest_additions.sh#' /etc/rc.local; " \ |
| 42 | + "echo 'Installation of VBox Guest Additions is proceeding in the background.'; " \ |
| 43 | + "echo '\"vagrant reload\" can be used in about 2 minutes to activate the new guest additions.'; " |
| 44 | + end |
| 45 | + # Add vagrant user to the docker group |
| 46 | + pkg_cmd << "usermod -a -G docker vagrant; " |
| 47 | + # Activate new kernel |
| 48 | + pkg_cmd << "shutdown -r +1; " |
| 49 | + pkg_cmd << "echo ---------- Kernel upgraded and Docker installed ----------; " |
| 50 | + pkg_cmd << "echo 'Please run \"vagrant reload\" in about 2 minutes to activate the new kernel and Docker.'" |
| 51 | + config.vm.provision :shell, :inline => pkg_cmd |
| 52 | + end |
| 53 | +end |
0 commit comments