Skip to content

Instantly share code, notes, and snippets.

@devlucas
Created February 19, 2017 02:18
Show Gist options
  • Save devlucas/190cf90080c9c3d5d8800078add478cd to your computer and use it in GitHub Desktop.
Save devlucas/190cf90080c9c3d5d8800078add478cd to your computer and use it in GitHub Desktop.
Simple Vagrantfile that checks for required plugins and installs them when they are missing.
# -*- mode: ruby -*-
required_plugins = %w(vagrant-exec vagrant-vbguest)
plugins_to_install = required_plugins.select do |plugin|
!Vagrant.has_plugin? plugin
end
unless plugins_to_install.empty?
puts "Installing plugins: #{plugins_to_install.join(' ')}"
if system "vagrant plugin install #{plugins_to_install.join(' ')}"
exec "vagrant #{ARGV.join(' ')}"
else
abort 'Installation of one or more plugins has failed. Aborting.'
end
end
Vagrant.configure(2) do |config|
config.vm.box = 'ubuntu/trusty64'
config.vm.provider 'virtualbox' do |v|
v.memory = 1024
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment