Skip to content

Instantly share code, notes, and snippets.

@p0deje
Last active Aug 29, 2015
Embed
What would you like to do?
Vagrantfile to develop and test Vagrant for Linux using DigitalOcean
# I'm running OS X and I need to develop and test Vagrant features
# which are specific to Linux-only, i.e. I need "physical" Linux machine.
# I've finally stuck with creating DigitalOcean VM and installing
# everything necessary for development there. It's magical
# Vagrant-powered Vagrant-development Vagrantfile.
#
# First, start the VM which will be the host:
# $ vagrant up host --provider=digital_ocean
#
# Now, you can start VM in VM which will be used for Vagrant testing:
# $ vagrant ssh host
# $ cd /vagrant
# $ bundle install
# $ bundle exec box add --name virtualbox http://files.vagrantup.com/precise32.box
# $ bundle exec vagrant up guest
#
# That's it!
#
# P.S. @vshvedov, you should love this!
Vagrant.configure('2') do |config|
config.vm.define 'host' do |host|
host.vm.box = 'digital_ocean'
host.vm.box_url = 'https://github.com/smdahlen/vagrant-digitalocean/raw/master/box/digital_ocean.box'
host.ssh.username = 'vagrant'
host.ssh.private_key_path = '~/.ssh/id_rsa'
host.vm.provider :digital_ocean do |digital_ocean|
digital_ocean.image = 'Ubuntu 12.04.3 x64'
digital_ocean.client_id = 'CLIENT_ID'
digital_ocean.api_key = 'API_KEY'
digital_ocean.region = 'Amsterdam 2'
digital_ocean.size = '2GB'
end
host.vm.provision :shell, inline: <<-SH
set -x
apt-get -y update
apt-get install -y git-core
apt-get install -y curl
apt-get install -y zlib1g-dev
apt-get install -y build-essential
apt-get install -y libssl-dev
apt-get install -y libreadline-dev
apt-get install -y libyaml-dev
apt-get install -y libxml2-dev
apt-get install -y libxslt1-dev
apt-get install -y bsdtar
apt-get install -y nfs-kernel-server
apt-get install -y linux-headers-generic
apt-get install -y linux-headers-`uname -r`
apt-get install -y virtualbox
wget http://ftp.ruby-lang.org/pub/ruby/2.1/ruby-2.1.0.tar.gz
tar -xzvf ruby-2.1.0.tar.gz
cd ruby-2.1.0/
./configure
make
make install
gem install bundler --no-ri --no-rdoc
SH
end
config.vm.define 'guest' do |guest|
guest.vm.box = 'virtualbox'
end
end
@vshvedov
Copy link

vshvedov commented Mar 7, 2014

I love this 👍

@mikhailov
Copy link

mikhailov commented Mar 7, 2014

Provider-agnostic, zero dependencies, never breaks style :)

echo "
      set -e
      apt-get -y update
      apt-get install -y build-essential zlib1g-dev 
      apt-get install -y libssl-dev libreadline-dev libyaml-dev libxml2-dev libxslt1-dev
      apt-get install -y git-core curl nfs-kernel-server
      apt-get install -y linux-headers-generic linux-headers-`uname -r`
      apt-get install -y virtualbox

      wget http://ftp.ruby-lang.org/pub/ruby/2.1/ruby-2.1.0.tar.gz
      tar -xzvf ruby-2.1.0.tar.gz && cd ruby-2.1.0/
      ./configure && make && make install

      gem install bundler --no-ri --no-rdoc " > setup.sh

ssh root@ip 'sudo bash -s' < ./setup.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment