Check vagrant version in Vagrantfile
To access the used version of vagrant in a vagrant file you can use the (undocumented) Vagrant::VERSION
constant. Combine this with Ruby's own Gem::Version
and you can create a nice switch to handle deprecated configuration in the Vagrantfile.
Here is an example:
One Comment
Respond to this post
Steffen Gebert wrote
Nice post, Christian!
In the upcoming version 1.4 of Vagrant, there will be even a function for that:
> The Vagrant.require_version function can be used at the top of a Vagrantfile to enforce a minimum/maximum Vagrant version.
https://github.com/mitchellh/vagrant/blob/master/CHANGELOG.md
But yes, you would lock out all users below 1.4, if you would use it once it's released ;-)
Steffen