how to detect from a Vagrantfile if a plugin has been installed?
-
20-12-2019 - |
Question
I would like to detect if a plugin has been installed, so I can add some useful debugging tips for users.
I have tried the following code:
if config.vbguest
config.vbguest.auto_update = true
else
puts "installing vagrant-vbguest plugin is recommended"
end
However, Vagrant outputs * Unknown configuration section 'vbguest'.
Is there a way I can detect whether a plugin has been installed?
Solution
The Vagrant.has_plugin?(name) method returns true if a plugin has been installed.
Example:
unless Vagrant.has_plugin?("vagrant-some-plugin")
raise 'some-plugin is not installed!'
end
Original source: stackoverflow answer.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow