-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVagrantfile
103 lines (85 loc) · 3.76 KB
/
Vagrantfile
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
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
## Generate a unique ID for this project
UUID = "OTYUID"
ports_map = { 'leaf01' => [1,2,8],
'leaf02' => [3,4,5,6],
'spine01' => [1,3],
'spine02' => [2,4],
'exit01' => [5,6,7,9],
'r01'=>[7,10]
}
host_port_map = { 'dc-host01' => 8,
'dmz-host01' => 9,
'ext-host01' => 10
}
vqfx_devices = ['leaf01','leaf02','spine01','spine02','exit01','r01']
host_devices = ['dc-host01', 'dmz-host01','ext-host01']
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.ssh.insert_key = false
vqfx_devices.each do |id|
re_name = ( id ).to_sym
pfe_name = ( id + "-pfe" ).to_sym
# ##############################
# ## Packet Forwarding Engine ##
# ##############################
config.vm.define pfe_name do |vqfxpfe|
vqfxpfe.ssh.insert_key = false
vqfxpfe.vm.box = 'juniper/vqfx10k-pfe'
# DO NOT REMOVE / NO VMtools installed
vqfxpfe.vm.synced_folder '.', '/vagrant', disabled: true
vqfxpfe.vm.network 'private_network', auto_config: false, nic_type: '82540EM', virtualbox__intnet: "#{UUID}_vqfx_internal_#{id}"
# In case you have limited resources, you can limit the CPU used per vqfx-pfe VM, usually 50% is good
# vqfxpfe.vm.provider "virtualbox" do |v|
# v.customize ["modifyvm", :id, "--cpuexecutioncap", "50"]
# end
end
##########################
## Routing Engine #######
##########################
config.vm.define re_name do |vqfx|
vqfx.vm.hostname = "#{id}"
vqfx.vm.box = 'juniper/vqfx10k-re'
# DO NOT REMOVE / NO VMtools installed
vqfx.vm.synced_folder '.', '/vagrant', disabled: true
# Management port
vqfx.vm.network 'private_network', auto_config: false, nic_type: '82540EM', virtualbox__intnet: "#{UUID}_vqfx_internal_#{id}"
vqfx.vm.network 'private_network', auto_config: false, nic_type: '82540EM', virtualbox__intnet: "#{UUID}_reserved_bridge"
# Dataplane ports
ports_map[id].each do |seg_id|
vqfx.vm.network 'private_network', auto_config: false, nic_type: '82540EM', virtualbox__intnet: "#{UUID}_seg#{seg_id}"
end
end
end
host_devices.each do |id|
##SERVERS
srv_name = ( id ).to_sym
config.vm.define srv_name do |srv|
srv.vm.box = "robwc/minitrusty64"
srv.vm.hostname = "#{id}"
srv.vm.network 'private_network', ip: "172.16.#{host_port_map[id]}.2", nic_type: '82540EM', virtualbox__intnet: "#{UUID}_seg#{host_port_map[id]}"
srv.ssh.insert_key = true
srv.vm.provision "shell",
inline: "sudo route add -net 172.16.0.0 netmask 255.255.0.0 gw 172.16.#{host_port_map[id]}.1"
end
end
##############################
## Box provisioning ###
## exclude Windows host ###
##############################
if !Vagrant::Util::Platform.windows?
config.vm.provision "ansible" do |ansible|
ansible.groups = {
"vqfx10k-pfe" => ["leaf01-pfe", "leaf01-pfe","spine01-pfe","spine02-pfe","exit01-pfe"],
"hosts" => ['dc-host01', 'dmz-host01','ext-host01'],
"leaf" => ["leaf01","leaf02","exit01"],
"spine" => ["spine01","spine02"],
"fabric:children" => ["leaf","spine"],
"edge" => ["r01"],
"all:children" => ["leaf", "spine","vqfx10k-pfe","hosts","edge"]
}
ansible.playbook = "pb.config.deploy-junos.yaml"
end
end
end