Skip to content

Commit

Permalink
Merge pull request #7650 from monotonee/automate-vagrantfile-install-…
Browse files Browse the repository at this point in the history
…versions

Updated Vagrantfile to automatically install more recent versions of software.
  • Loading branch information
sethvargo committed Jul 27, 2016
2 parents aba25fb + abc50e3 commit 6a48d69
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions Vagrantfile
Expand Up @@ -25,43 +25,49 @@ Vagrant.configure("2") do |config|
end
end

$shell = <<-CONTENTS
$shell = <<-'CONTENTS'
export DEBIAN_FRONTEND=noninteractive
MARKER_FILE="/usr/local/etc/vagrant_provision_marker"
RUBY_VER_REQ=$(awk '$1 == "s.required_ruby_version" { print $4 }' /vagrant/vagrant.gemspec | tr -d '"')
BUNDLER_VER_REQ=$(awk '/s.add_dependency "bundler"/ { print $4 }' /vagrant/vagrant.gemspec | tr -d '"')
# Only provision once
if [ -f "${MARKER_FILE}" ]; then
exit 0
fi
# Update apt
apt-get update
apt-get update --quiet
# Install basic dependencies
apt-get install -y build-essential bsdtar curl
apt-get install -qy build-essential bsdtar curl
# Import the mpapis public key to verify downloaded releases
su -l -c 'curl -sSL https://rvm.io/mpapis.asc | gpg -q --import -' vagrant
su -l -c 'gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3' vagrant
# Install RVM
su -l -c 'curl -sL https://get.rvm.io | bash -s stable' vagrant
# Add the vagrant user to the RVM group
#usermod -a -G rvm vagrant
# Install some Rubies
su -l -c 'rvm install 2.2.3' vagrant
su -l -c 'rvm --default use 2.2.3' vagrant
# Install latest Ruby that complies with Vagrant's version constraint
RUBY_VER_LATEST=$(su -l -c 'rvm list known' vagrant | tr '[]-' ' ' | awk "/^ ruby ${RUBY_VER_REQ:0:1}\./ { print \$2 }" | sort | tail -n1)
su -l -c "rvm install ${RUBY_VER_LATEST}" vagrant
su -l -c "rvm --default use ${RUBY_VER_LATEST}" vagrant
# Output the Ruby version (for sanity)
su -l -c 'ruby --version' vagrant
# Install Git
apt-get install -y git
apt-get install -qy git
# Prepare to run unit tests
su -l vagrant -c 'gem install bundler -v 1.12.5'
su -l vagrant -c 'cd /vagrant; bundle install'
# Upgrade Rubygems
su -l -c "rvm ${RUBY_VER_LATEST} do gem update --system" vagrant
# Install bundler and prepare to run unit tests
su -l -c "gem install bundler -v ${BUNDLER_VER_REQ}" vagrant
su -l -c 'cd /vagrant; bundle install' vagrant
# Automatically move into the shared folder, but only add the command
# if it's not already there.
Expand Down

0 comments on commit 6a48d69

Please sign in to comment.