浏览代码

Vagrantfile: Debian/Ubuntu + vagrant cachier multi-machine configuration

Update the Vagrantfile so that it is possible (and easier) to spin up Debian
7, Ubuntu 12.04 and Ubuntu 14.04 VMs. Although Vagrant allows spinning up all
of them simultaneously, there may be conflicts assigning host names and IP
addresses.

This Vagrantfile also enables the vagrant-cachier plugin (if installed) to
cache downloaded packages across subsequent runs of the same VM.

Running "vagrant up" will bring up only the Debian VM since it is the
officially supported Linux distributions. Ubuntu 12.04 and Ubuntu 14.04 must
be started explicitly by running either "vagrant up precise" or "vagrant up
trusty".
Lorenzo Villani 10 年前
父节点
当前提交
2882c65f16
共有 1 个文件被更改,包括 46 次插入18 次删除
  1. 46
    18
      Vagrantfile

+ 46
- 18
Vagrantfile 查看文件

@@ -1,15 +1,22 @@
1 1
 # -*- mode: ruby -*-
2
-# If you're having issues, upgrade to Vagrant 1.3.x. It generates an inventory automatically:
3
-# https://github.com/mitchellh/vagrant/blob/master/CHANGELOG.md#130-september-5-2013
4 2
 
5
-Vagrant.configure('2') do |config|
6
-  # Debian 7 is the officially supported Linux distribution
7
-  config.vm.box = 'box-cutter/debian75'
3
+Vagrant.configure("2") do |config|
4
+  #
5
+  # Common Settings
6
+  #
8 7
 
9
-  # Comment the entry above and uncomment one of these two entries
10
-  # below if you want to develop/test against Ubuntu 12.04/14.04.
11
-  # config.vm.box = 'box-cutter/ubuntu1204'
12
-  # config.vm.box = 'box-cutter/ubuntu1404'
8
+  config.vm.hostname = "sovereign.local"
9
+  config.vm.network "private_network", ip: "172.16.100.2"
10
+
11
+  config.vm.provision :ansible do |ansible|
12
+    ansible.playbook = "site.yml"
13
+    ansible.host_key_checking = false
14
+    ansible.extra_vars = { ansible_ssh_user: "vagrant", testing: true }
15
+
16
+    # ansible.tags = ["blog"]
17
+    # ansible.skip_tags = ["openvpn"]
18
+    # ansible.verbose = "vvvv"
19
+  end
13 20
 
14 21
   config.vm.provider :virtualbox do |v|
15 22
     v.memory = 512
@@ -19,18 +26,39 @@ Vagrant.configure('2') do |config|
19 26
     v.vmx["memsize"] = "512"
20 27
   end
21 28
 
22
-  config.vm.hostname = 'sovereign.local'
29
+  #
30
+  # vagrant-cachier
31
+  #
32
+  # Install the plugin by running: vagrant plugin install vagrant-cachier
33
+  # More information: https://github.com/fgrehm/vagrant-cachier
34
+  #
23 35
 
24
-  config.vm.network "private_network", ip: "172.16.100.2"
36
+  if Vagrant.has_plugin? "vagrant-cachier"
37
+    config.cache.enable :apt
38
+    config.cache.scope = :box
39
+  end
25 40
 
26
-  config.vm.provision :ansible do |ansible|
27
-    ansible.playbook = 'site.yml'
28
-    ansible.host_key_checking = false
29
-    ansible.extra_vars = { ansible_ssh_user: 'vagrant', testing: true }
41
+  #
42
+  # Debian 7 64-bit (officially supported)
43
+  #
30 44
 
31
-    # ansible.tags = ['blog']
32
-    # ansible.skip_tags = ['openvpn']
33
-    # ansible.verbose = 'vvvv'
45
+  config.vm.define "debian", primary: true do |debian|
46
+    debian.vm.box = "box-cutter/debian75"
34 47
   end
35 48
 
49
+  #
50
+  # Ubuntu 12.04 64-bit
51
+  #
52
+
53
+  config.vm.define "precise", autostart: false do |precise|
54
+    precise.vm.box = "box-cutter/ubuntu1204"
55
+  end
56
+
57
+  #
58
+  # Ubuntu 14.04 64-bit
59
+  #
60
+
61
+  config.vm.define "trusty", autostart: false do |trusty|
62
+    trusty.vm.box = "box-cutter/ubuntu1404"
63
+  end
36 64
 end

正在加载...
取消
保存