Browse code

vagrant; issue #113: Make Vagrantfile backward compatible with versions < 1.1

Daniel Mizyrycki authored on 2013/03/22 09:23:23
Showing 1 changed files
... ...
@@ -1,7 +1,7 @@
1 1
 # -*- mode: ruby -*-
2 2
 # vi: set ft=ruby :
3 3
 
4
-Vagrant.configure("1") do |config|
4
+def v10(config)
5 5
   # All Vagrant configuration is done here. The most common configuration
6 6
   # options are documented and commented below. For a complete reference,
7 7
   # please see the online documentation at vagrantup.com.
... ...
@@ -20,7 +20,7 @@ Vagrant.configure("1") do |config|
20 20
   # via the IP. Host-only networks can talk to the host machine as well as
21 21
   # any other machines on the same network, but cannot be accessed (through this
22 22
   # network interface) by any external networks.
23
-  # config.vm.network :hostonly, "192.168.33.10"
23
+  config.vm.network :hostonly, "192.168.33.10"
24 24
 
25 25
   # Assign this VM to a bridged network, allowing you to connect directly to a
26 26
   # network using the host's network device. This makes the VM appear as another
... ...
@@ -34,6 +34,9 @@ Vagrant.configure("1") do |config|
34 34
   # Share an additional folder to the guest VM. The first argument is
35 35
   # an identifier, the second is the path on the guest to mount the
36 36
   # folder, and the third is the path on the host to the actual folder.
37
+  if not File.exist? File.expand_path '~/docker'
38
+    Dir.mkdir(File.expand_path '~/docker')
39
+  end
37 40
   config.vm.share_folder "v-data", "~/docker", "~/docker"
38 41
 
39 42
   # Enable provisioning with Puppet stand alone.  Puppet manifests
... ...
@@ -99,7 +102,15 @@ Vagrant.configure("1") do |config|
99 99
   #   chef.validation_client_name = "ORGNAME-validator"
100 100
 end
101 101
 
102
-Vagrant.configure("2") do |config|
102
+"#{Vagrant::VERSION}" < "1.1.0" and Vagrant::Config.run do |config|
103
+  v10(config)
104
+end
105
+
106
+"#{Vagrant::VERSION}" >= "1.1.0" and Vagrant.configure("1") do |config|
107
+  v10(config)
108
+end
109
+
110
+"#{Vagrant::VERSION}" >= "1.1.0" and Vagrant.configure("2") do |config|
103 111
   config.vm.provider :aws do |aws|
104 112
 		config.vm.box = "dummy"
105 113
 		config.vm.box_url = "https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box"