Search code examples
vagrantvagrant-plugin

How to programmatically install vagrant plugins?


I have a Vagrant build that has a dependency on vagrant plugins.

I could document that users need to install those plugins, but ideally I would like to automatically install the required plugins.

How can I automatically install the required plugins as part of my build?


Solution

  • I found the answer on a blog post by Matt Cooper. This solution worked for me.

    The blog post describes adding the following lines to the top of your Vagrantfile:

    required_plugins = %w( vagrant-omnibus vagrant-aws )
    required_plugins.each do |plugin|
        exec "vagrant plugin install #{plugin};vagrant #{ARGV.join(" ")}" unless Vagrant.has_plugin? plugin || ARGV[0] == 'plugin'
    end