forked from ansible/workshops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
215 lines (190 loc) · 8.2 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
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
212
213
214
215
# Generic leaf-spine network topology for vagrant
#
#
#
# NOTE: in order to use this Vagrantfile you will need:
# -Vagrant(v1.8.6+) installed: http://www.vagrantup.com/downloads
# -Virtualbox installed: https://www.virtualbox.org/wiki/Downloads
Vagrant.require_version ">= 2.1.1"
$script = <<SCRIPT
git clone https://github.com/network-automation/workshops/
chown -R vagrant:vagrant workshops
cp /home/vagrant/workshops/vagrant-demo/ansible.cfg /home/vagrant/.ansible.cfg
cp /home/vagrant/workshops/vagrant-demo/etchosts /etc/hosts
yum install epel-release -y
yum install python-pip tree -y
pip install --upgrade pip
pip install git+https://github.com/ansible/ansible.git@devel
pip install netaddr
SCRIPT
Vagrant.configure("2") do |config|
simid = 20
# # FOR VYOS
# network_os = "samdoran/vyos"
# network_memory = 256
# FOR Arista vEOS
network_os = "veos"
network_memory = 2048
#FOR CUMULUS VX
# network_os = "CumulusCommunity/cumulus-vx"
# network_memory = 768
config.vm.provider "virtualbox" do |v|
v.gui=false
end
##### DEFINE VM for ansible tower #####
config.vm.define "ansible" do |device|
device.vm.hostname = "ansible"
device.vm.box = "ansible/tower"
device.vm.network :forwarded_port, guest: 22, host: 6010
device.vm.network "private_network", virtualbox__intnet: "#{simid}_mgmt", ip: "192.168.0.2"
device.vm.provision "shell", inline: $script
end
##### DEFINE VM for leaf01 #####
config.vm.define "leaf01" do |device|
device.vm.hostname = "leaf01"
device.vm.box = "#{network_os}"
device.vm.network "forwarded_port", guest: 22, host: 6001
device.vm.provider "virtualbox" do |v|
v.name = "#{simid}_leaf01"
v.customize ["modifyvm", :id, '--audiocontroller', 'AC97', '--audio', 'Null']
v.memory = network_memory
end
device.vm.provision "leaf01_shell_config", type: 'shell', inline: <<-SHELL
FastCli -p 15 -c "configure
hostname leaf01
int e1
no switchport
ip address 192.168.0.14/24
end
copy running-config startup-config"
SHELL
# see note here: https://github.com/pradels/vagrant-libvirt#synced-folders
device.vm.synced_folder ".", "/vagrant", disabled: true
# NETWORK INTERFACES
# eth1 mgmt network for ansible tower
device.vm.network "private_network", virtualbox__intnet: "#{simid}_mgmt", auto_config: false
# link for eth2 --> spine01:eth2
device.vm.network "private_network", virtualbox__intnet: "#{simid}_net2", auto_config: false
# link for eth3 --> spine02:eth2
device.vm.network "private_network", virtualbox__intnet: "#{simid}_net12", auto_config: false
device.vm.provider "virtualbox" do |vbox|
vbox.customize ['modifyvm', :id, '--nicpromisc2', 'allow-all']
vbox.customize ['modifyvm', :id, '--nicpromisc3', 'allow-all']
vbox.customize ['modifyvm', :id, '--nicpromisc4', 'allow-all']
vbox.customize ['modifyvm', :id, '--nicpromisc5', 'allow-all']
vbox.customize ['modifyvm', :id, '--nicpromisc6', 'allow-all']
vbox.customize ['modifyvm', :id, '--nicpromisc7', 'allow-all']
vbox.customize ['modifyvm', :id, '--nicpromisc8', 'allow-all']
end
end
##### DEFINE VM for leaf02 #####
config.vm.define "leaf02" do |device|
device.vm.hostname = "leaf02"
device.vm.box = "#{network_os}"
device.vm.network "forwarded_port", guest: 22, host: 6002
device.vm.provider "virtualbox" do |v|
v.name = "#{simid}_leaf02"
v.customize ["modifyvm", :id, '--audiocontroller', 'AC97', '--audio', 'Null']
v.memory = network_memory
end
# see note here: https://github.com/pradels/vagrant-libvirt#synced-folders
device.vm.provision "leaf02_shell_config", type: 'shell', inline: <<-SHELL
FastCli -p 15 -c "configure
hostname leaf02
int e1
no switchport
ip address 192.168.0.15/24
end
copy running-config startup-config"
SHELL
# see note here: https://github.com/pradels/vagrant-libvirt#synced-folders
device.vm.synced_folder ".", "/vagrant", disabled: true
# NETWORK INTERFACES
# eth1 mgmt network for ansible tower
device.vm.network "private_network", virtualbox__intnet: "#{simid}_mgmt", auto_config: false
# link for eth2 --> spine01:eth3
device.vm.network "private_network", virtualbox__intnet: "#{simid}_net13", auto_config: false
# link for eth3 --> spine02:eth3
device.vm.network "private_network", virtualbox__intnet: "#{simid}_net15", auto_config: false
device.vm.provider "virtualbox" do |vbox|
vbox.customize ['modifyvm', :id, '--nicpromisc2', 'allow-all']
vbox.customize ['modifyvm', :id, '--nicpromisc3', 'allow-all']
vbox.customize ['modifyvm', :id, '--nicpromisc4', 'allow-all']
vbox.customize ['modifyvm', :id, '--nicpromisc5', 'allow-all']
vbox.customize ['modifyvm', :id, '--nicpromisc6', 'allow-all']
vbox.customize ['modifyvm', :id, '--nicpromisc7', 'allow-all']
end
end
##### DEFINE VM for spine01 #####
config.vm.define "spine01" do |device|
device.vm.hostname = "spine01"
device.vm.box = "#{network_os}"
device.vm.network "forwarded_port", guest: 22, host: 6003
device.vm.provider "virtualbox" do |v|
v.name = "#{simid}_spine01"
v.customize ["modifyvm", :id, '--audiocontroller', 'AC97', '--audio', 'Null']
v.memory = network_memory
end
# see note here: https://github.com/pradels/vagrant-libvirt#synced-folders
device.vm.provision "spine01_shell_config", type: 'shell', inline: <<-SHELL
FastCli -p 15 -c "configure
hostname spine01
int e1
no switchport
ip address 192.168.0.10/24
end
copy running-config startup-config"
SHELL
# see note here: https://github.com/pradels/vagrant-libvirt#synced-folders
device.vm.synced_folder ".", "/vagrant", disabled: true
# NETWORK INTERFACES
# eth1 mgmt network for ansible tower
device.vm.network "private_network", virtualbox__intnet: "#{simid}_mgmt", auto_config: false
# link for spine01:eth2 --> leaf01:eth2
device.vm.network "private_network", virtualbox__intnet: "#{simid}_net2", auto_config: false
# link for spine01:eth3 --> leaf02:eth2
device.vm.network "private_network", virtualbox__intnet: "#{simid}_net13", auto_config: false
device.vm.provider "virtualbox" do |vbox|
vbox.customize ['modifyvm', :id, '--nicpromisc2', 'allow-all']
vbox.customize ['modifyvm', :id, '--nicpromisc3', 'allow-all']
vbox.customize ['modifyvm', :id, '--nicpromisc4', 'allow-all']
vbox.customize ['modifyvm', :id, '--nicpromisc5', 'allow-all']
end
end
##### DEFINE VM for spine02 #####
config.vm.define "spine02" do |device|
device.vm.hostname = "spine02"
device.vm.box = "#{network_os}"
device.vm.network "forwarded_port", guest: 22, host: 6004
device.vm.provider "virtualbox" do |v|
v.name = "#{simid}_spine02"
v.customize ["modifyvm", :id, '--audiocontroller', 'AC97', '--audio', 'Null']
v.memory = network_memory
end
# see note here: https://github.com/pradels/vagrant-libvirt#synced-folders
device.vm.provision "spine02_shell_config", type: 'shell', inline: <<-SHELL
FastCli -p 15 -c "configure
hostname spine02
int e1
no switchport
ip address 192.168.0.11/24
end
copy running-config startup-config"
SHELL
# see note here: https://github.com/pradels/vagrant-libvirt#synced-folders
device.vm.synced_folder ".", "/vagrant", disabled: true
# NETWORK INTERFACES
# eth1 mgmt network for ansible tower
device.vm.network "private_network", virtualbox__intnet: "#{simid}_mgmt", auto_config: false
# link for spine02:eth2 --> leaf01:eth3
device.vm.network "private_network", virtualbox__intnet: "#{simid}_net12", auto_config: false
# link for spine02:eth3 --> leaf02:eth3
device.vm.network "private_network", virtualbox__intnet: "#{simid}_net15", auto_config: false
device.vm.provider "virtualbox" do |vbox|
vbox.customize ['modifyvm', :id, '--nicpromisc2', 'allow-all']
vbox.customize ['modifyvm', :id, '--nicpromisc3', 'allow-all']
vbox.customize ['modifyvm', :id, '--nicpromisc4', 'allow-all']
vbox.customize ['modifyvm', :id, '--nicpromisc5', 'allow-all']
end
end
end