Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to detect from a Vagrantfile if a plugin has been installed?

Tags:

vagrant

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?

like image 855
Chris Snow Avatar asked Jan 08 '14 16:01

Chris Snow


People also ask

How do I check my vagrant plugins?

To view what plugins are installed into your Vagrant environment at any time, use the vagrant plugin list command. This will list the plugins that are installed along with their version.

What are vagrant plugins?

Plugins are powerful, first-class citizens that extend Vagrant using a well-documented, stable API that can withstand major version upgrades.

What is vagrant Vbguest?

vagrant-vbguest is a Vagrant plugin which automatically installs the host's VirtualBox Guest Additions on the guest system.


1 Answers

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.

like image 66
Chris Snow Avatar answered Sep 22 '22 01:09

Chris Snow