summaryrefslogtreecommitdiffstats
path: root/vagrant-demo/Vagrantfile
blob: 2892b954da6061ff2f4340938b756f360d361e1f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# -*- mode: ruby -*-
# vi: set ft=ruby :

#
# Vagrantfile to set up demo VMs and network connections
#
# Note: VirtualBox is currently the only provier supported for the demo.
#
# [ host1 VM ] <=== Internal Network "host1-vpp1" ===> [  vpp1 VM ]
# [  vpp1 VM ] <==+ Internal Network "vpp1-vpp2"  ===> [  vpp2 VM ]
# [  jaws VM ] <==+
# [  vpp1 VM ] <--- Private Network 192.168.10.x -+--> [   vbd VM ]
#                   (Mgmt network)                |
#                                                 +--> [  vpp2 VM ]
# [  vpp2 VM ] <=== Internal Network "host2-vpp2" ===> [ host2 VM ]
#
Vagrant.configure(2) do |config|

  config.ssh.forward_x11 = true

  # Add .gnupg dir in so folks can sign patches
  # Note, as gnupg puts socket files in that dir, we have
  # to be cautious and make sure we are dealing with a plain file
  homedir = File.expand_path("~/")
  Dir["#{homedir}/.gnupg/**/*"].each do |fname|
    if File.file?(fname)
      destname = fname.sub(Regexp.escape("#{homedir}/"),'')
      config.vm.provision "file", source: fname, destination: destname
    end
  end

  # Copy in the .gitconfig if it exists
  if File.file?(File.expand_path("~/.gitconfig"))
    config.vm.provision  "file", source: "~/.gitconfig", destination: ".gitconfig"
  end

  # vagrant-cachier caches apt/yum etc to speed subsequent
  # vagrant up
  # to enable, run
  # vagrant plugin install vagrant-cachier
  #
  if Vagrant.has_plugin?("vagrant-cachier")
    config.cache.scope = :box
  end

  # Define vpp1 VM, L3 mgmt interface (eth1) to vbd and vpp2 VMs,
  # L2 interface (GigabitEthernet0/9/0) to host1, and
  # L2 interface (GigabitEthernet0/a/0) to vpp2
  #
  # [  vpp1 VM ] <-- Private Network 192.168.10.x -+-> [   vbd VM ]
  #                  (Mgmt network)                |
  #                                                +-> [  vpp2 VM ]
  # [ host1 VM ] <== Internal Network "host1-vpp1" ==> [  vpp1 VM ]
  # [  vpp1 VM ] <== Internal Network "vpp1-vpp2"  ==> [  vpp2 VM ]
  #
 config.vm.define :vpp1 do |vpp1|
    vpp1.vm.box = "puppetlabs/ubuntu-14.04-64-nocm"
    # Mount karaf packages directory if specified
    if ENV.key?('KARAF_PACKAGES')
      vpp1.vm.synced_folder ENV['KARAF_PACKAGES'], "/karaf-packages", disabled: false
    end
    # Mount Maven repository if specified
    if ENV.key?('HONEYCOMB_M2_REPO')
      vpp1.vm.synced_folder ENV['HONEYCOMB_M2_REPO'], "/m2-repository", disabled: false
    end
    # Mount VPP repository if specified
    if ENV.key?('VPP_REPO')
      vpp1.vm.synced_folder ENV['VPP_REPO'], "/vpp", disabled: false
    end
    vpp1.vm.synced_folder "../", "/honeycomb", disabled: false
    vagrant_vpp_agent_addr = "192.168.10.11"
    vpp1.vm.network "private_network", ip: "#{vagrant_vpp_agent_addr}"
    vpp1.vm.provider "virtualbox" do |vb|
      vb.customize ["modifyvm", :id, "--nic3", "intnet"]
      vb.customize ["modifyvm", :id, "--intnet3", "host1-vpp1"]
      vb.customize ["modifyvm", :id, "--nicpromisc3", "allow-all"]
      vb.customize ["modifyvm", :id, "--nic4", "intnet"]
      vb.customize ["modifyvm", :id, "--intnet4", "vpp1-vpp2"]
      vb.customize ["modifyvm", :id, "--nicpromisc4", "allow-all"]
      vb.memory = "4096"
    end
    vpp1.vm.provision 'shell' do | s|
      s.path = "../vagrant/bootstrap.ubuntu1404.sh"
      s.args = ["vpp1", "is_vpp_agent", "#{vagrant_vpp_agent_addr}"]
    end
end

  # Define vpp2 VM, L3 mgmt interface (eth1) to vbd and vpp1 VMs,
  # L2 interface (GigabitEthernet0/9/0) to host1, and
  # L2 interface (GigabitEthernet0/a/0) to vpp1
  #
  # [  vpp1 VM ] <-- Private Network 192.168.10.x -+-> [   vbd VM ]
  #                  (Mgmt network)                |
  #                                                +-> [  vpp2 VM ]
  # [  vpp2 VM ] <== Internal Network "host2-vpp2" ==> [ host2 VM ]
  # [  vpp1 VM ] <== Internal Network "vpp1-vpp2"  ==> [  vpp2 VM ]
  #
 config.vm.define :vpp2 do |vpp2|
    # TODO: Run centos on vpp2 VM
    # vpp2.vm.box = "puppetlabs/centos-7.0-64-nocm"
    vpp2.vm.box = "puppetlabs/ubuntu-14.04-64-nocm"
    # Mount karaf packages directory if specified
    if ENV.key?('KARAF_PACKAGES')
      vpp2.vm.synced_folder ENV['KARAF_PACKAGES'], "/karaf-packages", disabled: false
    end
    # Mount Maven repository if specified
    if ENV.key?('HONEYCOMB_M2_REPO')
      vpp2.vm.synced_folder ENV['HONEYCOMB_M2_REPO'], "/m2-repository", disabled: false
    end
    # Mount VPP repository if specified
    if ENV.key?('VPP_REPO')
      vpp2.vm.synced_folder ENV['VPP_REPO'], "/vpp", disabled: false
    end
    vpp2.vm.synced_folder "../", "/honeycomb", disabled: false
    vagrant_vpp_agent_addr = "192.168.10.12"
    vpp2.vm.network "private_network", ip: "#{vagrant_vpp_agent_addr}"
    vpp2.vm.provider "virtualbox" do |vb|
      vb.customize ["modifyvm", :id, "--nic3", "intnet"]
      vb.customize ["modifyvm", :id, "--intnet3", "host2-vpp2"]
      vb.customize ["modifyvm", :id, "--nicpromisc3", "allow-all"]
      vb.customize ["modifyvm", :id, "--nic4", "intnet"]
      vb.customize ["modifyvm", :id, "--intnet4", "vpp1-vpp2"]
      vb.customize ["modifyvm", :id, "--nicpromisc4", "allow-all"]
      vb.memory = "4096"
    end
    vpp2.vm.provision 'shell' do | s|
      s.path = "../vagrant/bootstrap.ubuntu1404.sh"
      s.args = ["vpp2", "is_vpp_agent", "#{vagrant_vpp_agent_addr}"]
    end
  end
 
  # Define vbd VM and L3 mgmt interface (eth1) to vpp1 and vpp2 VMs
  #
  # [  vpp1 VM ] <-- Private Network 192.168.10.x -+-> [   vbd VM ]
  #                  (Mgmt network)                |
  #                                                +-> [  vpp2 VM ]
  #
  config.vm.define :vbd do |vbd|
    vbd.vm.box = "puppetlabs/ubuntu-14.04-64-nocm"
    # Mount karaf packages directory if specified
    if ENV.key?('KARAF_PACKAGES')
      vbd.vm.synced_folder ENV['KARAF_PACKAGES'], "/karaf-packages", disabled: false
    end
    # Mount Maven repository if specified
    if ENV.key?('HONEYCOMB_M2_REPO')
      vbd.vm.synced_folder ENV['HONEYCOMB_M2_REPO'], "/m2-repository", disabled: false
    end
    vbd.vm.synced_folder "../", "/honeycomb", disabled: false
    vbd.vm.network "private_network", ip: "192.168.10.10"
    vbd.vm.provider "virtualbox" do |vb|
      vb.memory = "2048"
    end
    vbd.vm.provision 'shell' do | s|
      s.path = "../vagrant/bootstrap.ubuntu1404.sh"
      s.args = ["vbd", "is_vbd_vm", ""]
    end
  end

  # Define host1 VM and L2 interface (eth1) to vpp1 VM
  #
  # [ host1 VM ] <== Internal Network "host1-vpp1" ==> [  vpp1 VM ]
  #
  config.vm.define :host1 do |host1|
    host1.vm.box = "puppetlabs/ubuntu-14.04-64-nocm"
    host1.vm.provider "virtualbox" do |vb|
      vb.customize ["modifyvm", :id, "--nic2", "intnet"]
      vb.customize ["modifyvm", :id, "--intnet2", "host1-vpp1"]
      vb.customize ["modifyvm", :id, "--nicpromisc2", "allow-all"]
    end
    host1.vm.provision "shell" do |s|
      s.path = "bootstrap-host.ubuntu1404.sh"
      s.args = ["host1", "172.16.15.14/24"]
    end
  end

  # Define host2 VM and L2 interface (eth1) to vpp2 VM
  #
  # [  vpp2 VM ] <== Internal Network "host2-vpp2" ==> [ host2 VM ]
  #
  config.vm.define :host2 do |host2|
    host2.vm.box = "puppetlabs/ubuntu-14.04-64-nocm"
    host2.vm.provider "virtualbox" do |vb|
      vb.customize ["modifyvm", :id, "--nic2", "intnet"]
      vb.customize ["modifyvm", :id, "--intnet2", "host2-vpp2"]
      vb.customize ["modifyvm", :id, "--nicpromisc2", "allow-all"]
    end
    host2.vm.provision "shell" do |s|
      s.path = "bootstrap-host.ubuntu1404.sh"
      s.args = ["host2", "172.16.15.15/24"]
    end
  end

  # Define jaws VM (for wireshark) connected to the vpp1 <-> vpp2
  # internal network.
  #
  # [  vpp1 VM ] <==+ Internal Network "vpp1-vpp2"  ===> [  vpp2 VM ]
  # [  jaws VM ] <==+
  #
  config.vm.define :jaws do |jaws|
    jaws.vm.box = "puppetlabs/ubuntu-14.04-64-nocm"
    jaws.vm.provider "virtualbox" do |vb|
      vb.customize ["modifyvm", :id, "--nic2", "intnet"]
      vb.customize ["modifyvm", :id, "--intnet2", "vpp1-vpp2"]
      vb.customize ["modifyvm", :id, "--nicpromisc2", "allow-all"]
    end
    jaws.vm.provision "shell" do |s|
      s.path = "bootstrap-host.ubuntu1404.sh"
      s.args = ["jaws", "172.16.15.15/24"]
    end
  end
end