Skip to content

Instantly share code, notes, and snippets.

@rogeriopradoj
Last active January 29, 2019 20:12
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save rogeriopradoj/6954261 to your computer and use it in GitHub Desktop.
Save rogeriopradoj/6954261 to your computer and use it in GitHub Desktop.
How to use Vagrant.has_plugin? -> small list of example plugins
How is listed with vagrant plugin list How to use in Vagrant.has_plugin? link to plugin.rb in repo
bindler Bindler fgrehm/bindler
vagrant-hostmanager HostManager smdahlen/vagrant-hostmanager
vagrant-cachier vagrant-cachier fgrehm/vagrant-cachier
vagrant-aws AWS mitchellh/vagrant-aws
vagrant-rackspace RackSpace Cloud mitchellh/vagrant-rackspace
vagrant-hp HP mohitsethi/vagrant-hp
vagrant-digitalocean DigitalOcean smdahlen/vagrant-digitalocean

Example when plugin is not installed

# Warns to use Bindler
unless Vagrant.has_plugin?("Bindler")
  puts "--- WARNING ---"
  puts "I'm using Bindler, https://github.com/fgrehm/bindler"
  puts "It's for 'Dead easy Vagrant plugins management'"
  puts "If you have not it installed in your system,"
  puts "visit https://github.com/fgrehm/bindler#installation for more information"
end

# Vagrant.configure("2") do |config| ...

Example when plugin is installed

# Vagrant.configure("2") do |config| ...

  # configs for vagrant-cachier
  if Vagrant.has_plugin?("vagrant-cachier")
    config.cache.auto_detect = true
  end
  
  # configs for vagrant-hostmanager
  if Vagrant.has_plugin?("HostManager")
    config.hostmanager.enabled = true
    config.hostmanager.manage_host = true
  end

# ...
@dennyweiss
Copy link

@rogeriopradoj Is the has_plugin method still available in vagrant version 1.7.3?

@lukeab
Copy link

lukeab commented Jun 16, 2016

I dont know about 1.7.3 but it is availble on 1.8.3 i'm using now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment