# Vagrantfile API/syntax version.
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure("#{VAGRANTFILE_API_VERSION}") do |config|
config.vm.box = "vyos/current"
# Disble SSH Replacement
config.ssh.insert_key = false
# Disable Plugin Updates
if Vagrant.has_plugin?("vagrant-vbguest")
config.vbguest.auto_update = false
end
# Configure Shared Folder
config.vm.synced_folder ".", "/vagrant", disabled: true
# VBOX
config.vm.provider "virtualbox" do |v|
v.memory = 1024
v.cpus = 1
end
# Spine Routers
$spine01_script = <<-SCRIPT
cat << EOF > /tmp/provision-template.sh
#!/bin/vbash
source /opt/vyatta/etc/functions/script-template
set system host-name spine01
set system domain-name the-packet-thrower.com
set interface loopback lo address 192.168.255.1/32
set interface ethernet eth1 address 10.1.11.254/24
set interface ethernet eth2 address 10.1.12.254/24
set interface ethernet eth3 address 10.1.13.254/24
set protocols ospf area 0 network 0.0.0.0/0
commit
EOF
SCRIPT
$spine02_script = <<-SCRIPT
cat << EOF > /tmp/provision-template.sh
#!/bin/vbash
source /opt/vyatta/etc/functions/script-template
set system host-name spine02
set system domain-name the-packet-thrower.com
set interface loopback lo address 192.168.255.2/32
set interface ethernet eth1 address 10.2.11.254/24
set interface ethernet eth2 address 10.2.12.254/24
set interface ethernet eth3 address 10.2.13.254/24
set protocols ospf area 0 network 0.0.0.0/0
commit
EOF
SCRIPT
# Leaf Routers
$leaf01_script = <<-SCRIPT
cat << EOF > /tmp/provision-template.sh
#!/bin/vbash
source /opt/vyatta/etc/functions/script-template
set system host-name leaf01
set system domain-name the-packet-thrower.com
set interface loopback lo address 192.168.255.11/32
set interface ethernet eth1 address 10.1.11.1/24
set interface ethernet eth2 address 10.2.11.254/24
set protocols ospf area 0 network 0.0.0.0/0
commit
EOF
SCRIPT
$leaf02_script = <<-SCRIPT
cat << EOF > /tmp/provision-template.sh
#!/bin/vbash
source /opt/vyatta/etc/functions/script-template
set system host-name leaf02
set system domain-name the-packet-thrower.com
set interface loopback lo address 192.168.255.12/32
set interface ethernet eth1 address 10.1.12.1/24
set interface ethernet eth2 address 10.2.12.254/24
set protocols ospf area 0 network 0.0.0.0/0
commit
EOF
SCRIPT
$leaf03_script = <<-SCRIPT
cat << EOF > /tmp/provision-template.sh
#!/bin/vbash
source /opt/vyatta/etc/functions/script-template
set system host-name leaf03
set system domain-name the-packet-thrower.com
set interface loopback lo address 192.168.255.13/32
set interface ethernet eth1 address 10.1.13.1/24
set interface ethernet eth2 address 10.2.13.254/24
set protocols ospf area 0 network 0.0.0.0/0
commit
EOF
SCRIPT
(1..2).each do |i|
config.vm.define "SPINE0#{i}" do |spine|
spine.vm.network "private_network", auto_config: false, virtualbox__intnet: "spine0#{i}_to_leaf01"
spine.vm.network "private_network", auto_config: false, virtualbox__intnet: "spine0#{i}_to_leaf02"
spine.vm.network "private_network", auto_config: false, virtualbox__intnet: "spine0#{i}_to_leaf03"
spine.vm.provider :virtualbox do |vb|
vb.customize ['modifyvm',:id,'--nicpromisc2','allow-all']
vb.customize ['modifyvm',:id,'--nicpromisc3','allow-all']
vb.customize ['modifyvm',:id,'--nicpromisc4','allow-all']
end
if i === 1
spine.vm.provision "shell", inline: $spine01_script
end
if i === 2
spine.vm.provision "shell", inline: $spine02_script
end
spine.vm.provision "shell", inline: <<-EOC
chmod 777 /tmp/provision-template.sh
sg vyattacfg -c /tmp/provision-template.sh
EOC
end
end
# Leaf Routers
(1..3).each do |i|
config.vm.define "LEAF0#{i}" do |leaf|
leaf.vm.network "private_network", auto_config: false, virtualbox__intnet: "spine01_to_leaf0#{i}"
leaf.vm.network "private_network", auto_config: false, virtualbox__intnet: "spine02_to_leaf0#{i}"
leaf.vm.provider :virtualbox do |vb|
vb.customize ['modifyvm',:id,'--nicpromisc2','allow-all']
vb.customize ['modifyvm',:id,'--nicpromisc3','allow-all']
end
if i === 1
leaf.vm.provision "shell", inline: $leaf01_script
end
if i === 2
leaf.vm.provision "shell", inline: $leaf02_script
end
if i === 3
leaf.vm.provision "shell", inline: $leaf03_script
end
leaf.vm.provision "shell", inline: <<-EOC
chmod 777 /tmp/provision-template.sh
sg vyattacfg -c /tmp/provision-template.sh
EOC
end
end
end
Comments
0 B
|👍
/👎
0 B
|👍
/👎