diff options
| author | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
| commit | 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch) | |
| tree | f1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/vagrant/providers%2Fbasic_usage.html | |
new repository
Diffstat (limited to 'devdocs/vagrant/providers%2Fbasic_usage.html')
| -rw-r--r-- | devdocs/vagrant/providers%2Fbasic_usage.html | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/devdocs/vagrant/providers%2Fbasic_usage.html b/devdocs/vagrant/providers%2Fbasic_usage.html new file mode 100644 index 00000000..4793dfe7 --- /dev/null +++ b/devdocs/vagrant/providers%2Fbasic_usage.html @@ -0,0 +1,27 @@ +<h1 id="basic-provider-usage"> Basic Provider Usage </h1> <h2 id="boxes"> Boxes </h2> <p>Vagrant boxes are all provider-specific. A box for VirtualBox is incompatible with the VMware Fusion provider, or any other provider. A box must be installed for each provider, and can share the same name as other boxes as long as the providers differ. So you can have both a VirtualBox and VMware Fusion "precise64" box.</p> <p>Installing boxes has not changed at all:</p> <div class="highlight"><pre class="highlight plaintext">$ vagrant box add hashicorp/precise64 +</pre></div> +<p>Vagrant now automatically detects what provider a box is for. This is visible when listing boxes. Vagrant puts the provider in parentheses next to the name, as can be seen below.</p> <div class="highlight"><pre class="highlight plaintext">$ vagrant box list +precise64 (virtualbox) +precise64 (vmware_fusion) +</pre></div> +<h2 id="vagrant-up"> Vagrant Up </h2> <p>Once a provider is installed, you can use it by calling <code>vagrant up</code> with the <code>--provider</code> flag. This will force Vagrant to use that specific provider. No other configuration is necessary!</p> <p>In normal day-to-day usage, the <code>--provider</code> flag is not necessary since Vagrant can usually pick the right provider for you. More details on how it does this is below.</p> <div class="highlight"><pre class="highlight plaintext">$ vagrant up --provider=vmware_fusion +</pre></div> +<p>If you specified a <code>--provider</code> flag, you only need to do this for the <code>up</code> command. Once a machine is up and running, Vagrant is able to see what provider is backing a running machine, so commands such as <code>destroy</code>, <code>suspend</code>, etc. do not need to be told what provider to use.</p> <blockquote class="alert alert-info"> <p>Vagrant currently restricts you to bringing up one provider per machine. If you have a multi-machine environment, you can bring up one machine backed by VirtualBox and another backed by VMware Fusion, for example, but you cannot back the <em>same machine</em> with both VirtualBox and VMware Fusion. This is a limitation that will be removed in a future version of Vagrant.</p> </blockquote> +<h2 id="default-provider"> Default Provider </h2> <p>As mentioned earlier, you typically do not need to specify <code>--provider</code> <em>ever</em>. Vagrant is smart enough about being able to detect the provider you want for a given environment.</p> <p>Vagrant attempts to find the default provider in the following order:</p> <ol> <li> +<p>The <code>--provider</code> flag on a <code>vagrant up</code> is chosen above all else, if it is present.</p> </li> <li> +<p>If the <code>VAGRANT_DEFAULT_PROVIDER</code> environmental variable is set, it takes next priority and will be the provider chosen.</p> </li> <li> +<p>Vagrant will go through all of the <code>config.vm.provider</code> calls in the Vagrantfile and try each in order. It will choose the first provider that is usable. For example, if you configure Hyper-V, it will never be chosen on Mac this way. It must be both configured and usable.</p> </li> <li> +<p>Vagrant will go through all installed provider plugins (including the ones that come with Vagrant), and find the first plugin that reports it is usable. There is a priority system here: systems that are known better have a higher priority than systems that are worse. For example, if you have the VMware provider installed, it will always take priority over VirtualBox.</p> </li> <li> +<p>If Vagrant still has not found any usable providers, it will error.</p> </li> </ol> <p>Using this method, there are very few cases that Vagrant does not find the correct provider for you. This also allows each <a href="../vagrantfile/index">Vagrantfile</a> to define what providers the development environment is made for by ordering provider configurations.</p> <p>A trick is to use <code>config.vm.provider</code> with no configuration at the top of your Vagrantfile to define the order of providers you prefer to support:</p> <div class="highlight"><pre class="highlight ruby" data-language="ruby">Vagrant.configure("2") do |config| + # ... other config up here + + # Prefer VMware Fusion before VirtualBox + config.vm.provider "vmware_fusion" + config.vm.provider "virtualbox" +end +</pre></div><div class="_attribution"> + <p class="_attribution-p"> + © 2010–2018 Mitchell Hashimoto<br>Licensed under the MPL 2.0 License.<br> + <a href="https://www.vagrantup.com/docs/providers/basic_usage.html" class="_attribution-link">https://www.vagrantup.com/docs/providers/basic_usage.html</a> + </p> +</div> |
