From 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 7 Apr 2024 13:41:34 -0500 Subject: new repository --- devdocs/vagrant/vagrantfile%2Fversion.html | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 devdocs/vagrant/vagrantfile%2Fversion.html (limited to 'devdocs/vagrant/vagrantfile%2Fversion.html') diff --git a/devdocs/vagrant/vagrantfile%2Fversion.html b/devdocs/vagrant/vagrantfile%2Fversion.html new file mode 100644 index 00000000..81ea1ecc --- /dev/null +++ b/devdocs/vagrant/vagrantfile%2Fversion.html @@ -0,0 +1,18 @@ +

Configuration Version

Configuration versions are the mechanism by which Vagrant 1.1+ is able to remain backwards compatible with Vagrant 1.0.x Vagrantfiles, while introducing dramatically new features and configuration options.

If you run vagrant init today, the Vagrantfile will be in roughly the following format:

Vagrant.configure("2") do |config|
+  # ...
+end
+
+

The "2" in the first line above represents the version of the configuration object config that will be used for configuration for that block (the section between the do and the end). This object can be very different from version to version.

Currently, there are only two supported versions: "1" and "2". Version 1 represents the configuration from Vagrant 1.0.x. "2" represents the configuration for 1.1+ leading up to 2.0.x.

When loading Vagrantfiles, Vagrant uses the proper configuration object for each version, and properly merges them, just like any other configuration.

The important thing to understand as a general user of Vagrant is that within a single configuration section, only a single version can be used. You cannot use the new config.vm.provider configurations in a version 1 configuration section. Likewise, config.vm.forward_port will not work in a version 2 configuration section (it was renamed).

If you want, you can mix and match multiple configuration versions in the same Vagrantfile. This is useful if you found some useful configuration snippet 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.x did configuration. In Vagrant 1.1+, this is synonymous with Vagrant.configure("1").

+

+ © 2010–2018 Mitchell Hashimoto
Licensed under the MPL 2.0 License.
+ https://www.vagrantup.com/docs/vagrantfile/version.html +

+
-- cgit v1.2.3