Automatically installing Vagrant plugin dependencies

Following on from my post on Customising Vagrant behaviour another handy thing you can do with your Vagrantfile and some simple Ruby is install your plugin dependencies automatically.

Say you are distributing a Vagrant config to your team. You might require them to have vagrant-omnibus and vagrant-aws installed so that they can provision servers on AWS with Chef. Ordinarily you would need to provide them with instructions on installing these plugins, but wouldn’t it be great if they could just:

With a bit of Ruby you can install these plugins automatically for them and all they have to do is simply run vagrant up and all systems are go.

Add the following to the top of your Vagrantfile changing the first line to have the plugins you require:

Now everytime Vagrant is run it will quickly check that all of the plugins you require are installed. If a plugin is missing it will be installed and then Vagrant will be re-run with the same arguments you originally provided.