Add a "force yes" switch to automatically install plugins on vagrant up (and other commands)
Is your feature request related to a problem? Please describe.
The config.vagrant.plugins directive is really handy to automatically install plugins, but I found no way to force the installation without asking questions. This makes it unsuitable where you need total automated, such as CI builds (an example).
Example (configuration directive in a Vagrantfile):
config.vagrant.plugins = {
"vagrant-hostsupdater" => {"version" => "1.1.1"}
}
Example output:
Vagrant has detected project local plugins configured for this
project which are not installed.
vagrant-hostsupdater
Install local plugins (Y/N) [N]:
Describe the solution you'd like
Have a switch to force the installation of plugins, or a more general --force switch, such as the one that vagrant destroy accepts.
Describe alternatives you've considered Installing the plugins before bringing up the environment, but this leads to duplication.
config.vagrant.plugins is installing the plugins in the local project, and yes, but I've found another workaround for bypassing the user input. The only downside is that it is installing the plugins globally, instead of installing them in the local project
unless Vagrant.has_plugin?("vagrant-vbguest")
system('vagrant plugin install vagrant-vbguest')
exit system('vagrant', *ARGV)
end
unless Vagrant.has_plugin?("vagrant-hostmanager")
system('vagrant plugin install vagrant-hostmanager')
exit system('vagrant', *ARGV)
end
unless Vagrant.has_plugin?("vagrant-puppet-install")
system('vagrant plugin install vagrant-puppet-install')
exit system('vagrant', *ARGV)
end
or
VAGRANT_PLUGINS = [
"vagrant-vbguest",
"vagrant-hostmanager",
"vagrant-puppet-install",
]
VAGRANT_PLUGINS.each do |plugin|
unless Vagrant.has_plugin?("#{plugin}")
system("vagrant plugin install #{plugin}")
exit system('vagrant', *ARGV)
end
end
exit system('vagrant', *ARGV) is used relaunching Vagrant so the plugin is detected.
Before running vagrant up:
$ vagrant plugin list
No plugins installed.
Output during vagrant up:
$ vagrant up
Installing the 'vagrant-vbguest' plugin. This can take a few minutes...
Fetching micromachine-3.0.0.gem
Fetching vagrant-vbguest-0.28.0.gem
Installed the plugin 'vagrant-vbguest (0.28.0)'!
Installing the 'vagrant-hostmanager' plugin. This can take a few minutes...
Fetching vagrant-hostmanager-1.8.9.gem
Installed the plugin 'vagrant-hostmanager (1.8.9)'!
Installing the 'vagrant-puppet-install' plugin. This can take a few minutes...
Fetching vagrant-puppet-install-6.0.1.gem
Installed the plugin 'vagrant-puppet-install (6.0.1)'!
And listing the vagrant plugins globally installed:
$ vagrant plugin list
vagrant-hostmanager (1.8.9, global)
vagrant-puppet-install (6.0.1, global)
vagrant-vbguest (0.28.0, global)
I followed this but realized that Vagrant has a check and seems to think that the box is being accessed by the other vagrant process still. So it won't complete the vagrant up command, and I have to run vagrant up again.
Bringing machine 'default' up with 'hyperv' provider...
An action 'up' was attempted on the machine 'default',
but another process is already executing an action on the machine.
Vagrant locks each machine for access by only one process at a time.
Please wait until the other Vagrant process finishes modifying this
machine, then try again.
If you believe this message is in error, please check the process listing
for any "ruby" or "vagrant" processes and kill them. Then try again.
Any way to get around this?