Skip to content

Instantly share code, notes, and snippets.

@ampvchen
Last active May 6, 2019 01:47
Embed
What would you like to do?
Ruby Vagrant
# -*- mode: ruby -*-
# vi: set ft=ruby :
RUBY_ARCHIVE = {
"linux" => "ruby-2.4.1",
}
INSTALL = {
"linux" => "apt-get update -qq; apt-get install -qq -y git curl tmux zsh ",
}.freeze
# shell script to bootstrap ruby
def bootstrap(box)
install = INSTALL[box]
archive = RUBY_ARCHIVE[box]
vagrant_home = "/home/vagrant"
<<-SCRIPT
#{install}
apt-get update -qq
apt-get install -qq -y build-essential autoconf automake bison libtool
apt-get install -qq -y libffi-dev libyaml-dev libsqlite3-dev libxml2-dev
apt-get install -qq -y libc6-dev libgdbm-dev ncurses-dev
apt-get install -qq -y zlibc zlib1g zlib1g-dev
apt-get install -qq -y openssl libssl-dev libreadline-dev
if ! [ -f /home/vagrant/#{archive}.tar.gz ]; then
curl -O# https://cache.ruby-lang.org/pub/ruby/#{archive}.tar.gz
fi
chown -R vagrant:vagrant /usr/local
tar -C /home/vagrant -xzf #{archive}.tar.gz
cd #{archive}
./configure
make && make install
source #{vagrant_home}/.bashrc
SCRIPT
end
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.provision :shell, :inline => bootstrap("linux")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment