Skip to content

Instantly share code, notes, and snippets.

@canimus
Last active October 13, 2015 14:01
Show Gist options
  • Save canimus/132e784926895b12b971 to your computer and use it in GitHub Desktop.
Save canimus/132e784926895b12b971 to your computer and use it in GitHub Desktop.
Steps to create a new vagrant box from a base box
# Initialize Vagrantfile from base box
vagrant init ubuntu/trusty64
# Startup the box
vagrant up
# SSH to the box
vagrant ssh
# Update software
sudo apt-get update
# Upgrade components
sudo apt-get upgrade
# Install Ruby Version Manager
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
# Download Stable RVM Version
\curl -sSL https://get.rvm.io | bash -s stable
# Source the RVM Script
source /home/vagrant/.rvm/scripts/rvm
# Install latest ruby
rvm install ruby-2.2.1
# Use by default the latest installed ruby
rvm use ruby-2.2.1 --default
# Clean box
sudo apt-get clean
# Add zero out
sudo dd if=/dev/zero of=/EMPTY bs=1M
sudo rm -f /EMPTY
# Clear the bash history
cat /dev/null > ~/.bash_history && history -c && exit
# Repackage new box
vagrant package --output ubuntu-ruby.box
# Add box to vagrant install
vagrant box add ubuntu-ruby ubuntu-ruby.box
# Destroy the vagrant box
vagrant destroy
# Remove the Vagrantfile
rm Vagrantfile
# Initialize the new vagrant box
vagrant init ubuntu-ruby
# Configure new Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu-ruby"
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.hostname = "zion"
config.vm.synced_folder ".", "/home/ubuntu", :mount_options => ["dmode=777", "fmode=666"]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment