Skip to content

Instantly share code, notes, and snippets.

@EdwardPrentice
Created April 8, 2019 09:32
Show Gist options
  • Save EdwardPrentice/40d630d9776a270f19dfe93b427f1158 to your computer and use it in GitHub Desktop.
Save EdwardPrentice/40d630d9776a270f19dfe93b427f1158 to your computer and use it in GitHub Desktop.
Automatically install required plugins used within a Vagrantfile
if ARGV[0] != 'plugin'
required_plugins = ['vagrant-vbguest', 'vagrant-reload']
plugins_to_install = required_plugins.select { |plugin| not Vagrant.has_plugin? plugin }
if not 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
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment