From d0cdf7f5a295174379cf2faac249e21d0b22da87 Mon Sep 17 00:00:00 2001 From: Scott Lowe Date: Tue, 5 Apr 2016 15:42:58 -0600 Subject: [PATCH 1/2] Switch to overrides instead of environment variables Modify Vagrantfile to use provider overrides instead of relying on environment variables. --- vagrant-multi-platform/Vagrantfile | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/vagrant-multi-platform/Vagrantfile b/vagrant-multi-platform/Vagrantfile index e4a7b7f..a45e742 100644 --- a/vagrant-multi-platform/Vagrantfile +++ b/vagrant-multi-platform/Vagrantfile @@ -25,14 +25,8 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| srv.vm.box_check_update = false srv.vm.hostname = machine['name'] - # Specify box based on default provider environment variable - if ENV['VAGRANT_DEFAULT_PROVIDER'] == 'vmware_fusion' - srv.vm.box = machine['vmw_box'] - elsif ENV['VAGRANT_DEFAULT_PROVIDER'] == 'virtualbox' - srv.vm.box = machine['vb_box'] - else - srv.vm.box = nil - end # if ENV['VAGRANT_DEFAULT_PROVIDER'] + # Set box to VMware Fusion box by default + srv.vm.box = machine['vmw_box'] # Disable default synced folder srv.vm.synced_folder '.', '/vagrant', disabled: true @@ -44,9 +38,10 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| end # srv.vm.provider vmware_fusion # Configure the VM with RAM and CPUs per machines.yml (VirtualBox) - srv.vm.provider 'virtualbox' do |vb| + srv.vm.provider 'virtualbox' do |vb, override| vb.memory = machine['ram'] vb.cpus = machine['vcpu'] + override.vm.box = machine['vb_box'] end # srv.vm.provider virtualbox end # config.vm.define end # machines.each From a0b9d746a46fee9d21fe6a1ef6ec91a55c51fa5c Mon Sep 17 00:00:00 2001 From: Scott Lowe Date: Tue, 5 Apr 2016 15:48:46 -0600 Subject: [PATCH 2/2] Finalize new multi-platform environment Remove environment variable files as they are no longer needed (using provider overrides instead). Update README.md accordingly. --- vagrant-multi-platform/README.md | 10 ++-------- vagrant-multi-platform/vbrc | 1 - vagrant-multi-platform/vmwrc | 1 - 3 files changed, 2 insertions(+), 10 deletions(-) delete mode 100644 vagrant-multi-platform/vbrc delete mode 100644 vagrant-multi-platform/vmwrc diff --git a/vagrant-multi-platform/README.md b/vagrant-multi-platform/README.md index b596818..8f66432 100644 --- a/vagrant-multi-platform/README.md +++ b/vagrant-multi-platform/README.md @@ -13,10 +13,6 @@ These files were created to test a method of providing a single Vagrant ([http:/ * **Vagrantfile**: This file is used by Vagrant to spin up the virtual machines. This file is fairly extensively commented to help explain what's happening. You should be able to use this file unchanged; all the VM configuration options are stored outside this file. -* **vbrc**: This file simply sets the "DEFAULT_VAGRANT_PROVIDER" environment variable to "virtualbox". Use the `source` command to pull in this definition on systems running VirtualBox **before** using any Vagrant commands. - -* **vmwrc**: This file simply sets the "DEFAULT_VAGRANT_PROVIDER" environment variable to "vmware_fusion". Use the `source` command to pull in this definition on systems running VMware Fusion **before** using any Vagrant commands. - ## Instructions These instructions assume you've already installed Vagrant, the necessary back-end virtualization provider(s) (only VirtualBox and VMware Fusion are supported by this testing environment), and any necessary plugins. Please refer to the documentation for those products for more information on installation or configuration. @@ -25,10 +21,8 @@ These instructions assume you've already installed Vagrant, the necessary back-e 2. Edit the `machines.yml` file to ensure the box(es) you downloaded in step 1 is/are specified in this file. Place the name of the VirtualBox box as the value for "vb_box"; supply the name of the VMware Fusion box as the value for "vmw_box". -3. Run `source vbrc` (to use VirtualBox) or `source vmwrc` (to use VMware Fusion). +3. Run `vagrant up`. Vagrant will create the VM using the box specified in `machines.yml`, selecting the appropriate box based on the provider in use. -4. Run `vagrant up`. Vagrant will create the VM using the box specified in `machines.yml`, selecting the appropriate box based on the value of the environment variable. - -5. For ideal results, test this environment on different systems with different providers (i.e., a Linux system running VirtualBox and an OS X system running VMware Fusion). You'll see that, aside from the environment variables, no changes are required to either `Vagrantfile` or `machines.yml`. +5. For ideal results, test this environment on different systems with different providers (i.e., a Linux system running VirtualBox and an OS X system running VMware Fusion). No changes should be required to either `Vagrantfile` or `machines.yml` as you switch back and forth between systems. Enjoy! diff --git a/vagrant-multi-platform/vbrc b/vagrant-multi-platform/vbrc deleted file mode 100644 index 9f604b2..0000000 --- a/vagrant-multi-platform/vbrc +++ /dev/null @@ -1 +0,0 @@ -export VAGRANT_DEFAULT_PROVIDER=virtualbox \ No newline at end of file diff --git a/vagrant-multi-platform/vmwrc b/vagrant-multi-platform/vmwrc deleted file mode 100644 index aed14cc..0000000 --- a/vagrant-multi-platform/vmwrc +++ /dev/null @@ -1 +0,0 @@ -export VAGRANT_DEFAULT_PROVIDER=vmware_fusion \ No newline at end of file