» Configuration Version
Configuration versions are the mechanism by which Vagrant 1.1+ is ableto remain backwards compatiblewith Vagrant 1.0.x Vagrantfiles, while introducing dramatically new featuresand configuration options.
If you run vagrant init
today, the Vagrantfile will be in roughly thefollowing format:
Vagrant.configure("2") do |config|
# ...
end
The "2"
in the first line above represents the version of the configurationobject config
that will be used for configuration for that block (thesection between the do
and the end
). This object can be verydifferent from version to version.
Currently, there are only two supported versions: "1" and "2". Version 1represents the configuration from Vagrant 1.0.x. "2" represents the configurationfor 1.1+ leading up to 2.0.x.
When loading Vagrantfiles, Vagrant uses the proper configuration objectfor each version, and properly merges them, just like any other configuration.
The important thing to understand as a general user of Vagrant is thatwithin a single configuration section, only a single version can be used.You cannot use the new config.vm.provider
configurations in a version 1configuration section. Likewise, config.vm.forward_port
will not workin a version 2 configuration section (it was renamed).
If you want, you can mix and match multiple configuration versions in thesame Vagrantfile. This is useful if you found some useful configurationsnippet or something that you want to use. Example:
Vagrant.configure("1") do |config|
# v1 configs...
end
Vagrant.configure("2") do |config|
# v2 configs...
end
What is Vagrant::Config.run
?You may see this in Vagrantfiles. This was actually how Vagrant 1.0.xdid configuration. In Vagrant 1.1+, this is synonymous withVagrant.configure("1")
.