Check vagrant version in Vagrantfile

To access the used version of vagrant in a vagrant file you can use the (undocumented) Vagrant::VERSIONconstant. 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:

if Gem::Version.new(Vagrant::VERSION) >= Gem::Version.new('1.2')
  share_folder_options = {:create => true, :nfs => false, :mount_options => ['dmode=777','fmode=777']}
else
  share_folder_options = {:create => true, :nfs => false, :extra => 'dmode=777,fmode=777'}
end

keep on reading