local@host:~/vagrant$ vi Vagrantfile
#Set the default provider to libvirt in the case they forget --provider=libvirt or if someone destroys a machine it reverts to virtualbox ENV['VAGRANT_DEFAULT_PROVIDER'] = 'libvirt'
# Check required plugins
REQUIRED_PLUGINS_LIBVIRT = %w(vagrant-libvirt)
exit unless REQUIRED_PLUGINS_LIBVIRT.all? do |plugin|
Vagrant.has_plugin?(plugin) || (
puts "The #{plugin} plugin is required. Please install it with:"
puts "$ vagrant plugin install #{plugin}"
false
)
end
$script = <<-SCRIPT
echo "### RUNNING CUMULUS EXTRA CONFIG ###"
source /etc/lsb-release
echo " INFO: Detected Cumulus Linux v$DISTRIB_RELEASE Release"
echo "### Disabling default remap on Cumulus VX..."
mv -v /etc/hw_init.d/S10rename_eth_swp.sh /etc/S10rename_eth_swp.sh.backup &> /dev/null
echo "### Giving Vagrant User Ability to Run NCLU Commands ###"
adduser vagrant netedit
adduser vagrant netshow
echo "### DONE ###"
echo "### Rebooting Device to Apply Remap..."
nohup bash -c 'sleep 10; shutdown now -r "Rebooting to Remap Interfaces"' &
SCRIPT
Vagrant.configure("2") do |config|
config.ssh.forward_agent = true
wbid = 1
offset = wbid * 100
config.vm.provider :libvirt do |domain|
domain.management_network_address = "10.255.#{wbid}.0/24"
domain.management_network_name = "wbr#{wbid}"
end
####DEFINE VM for spine01 #####
config.vm.define "spine01" do |device|
device.vm.hostname = "spine01"
device.vm.box = "CumulusCommunity/cumulus-vx"
device.vm.box_version = "4.2.0"
device.vm.provider :libvirt do |v|
v.memory = 768
v.cpus = 2
end
# see note here: https://github.com/pradels/vagrant-libvirt#synced-folders
device.vm.synced_folder ".", "/vagrant", disabled: true
# link for swp1 --> leaf01:swp1
device.vm.network "private_network",
:mac => "44:38:39:00:00:01",
:libvirt__tunnel_type => 'udp',
:libvirt__tunnel_local_ip => '127.0.0.1',
:libvirt__tunnel_local_port => "#{ 8001 + offset }",
:libvirt__tunnel_ip => '127.0.0.1',
:libvirt__tunnel_port => "#{ 9001 + offset }",
:libvirt__iface_name => 'swp1',
auto_config: false
# link for swp2 --> leaf02:swp1
device.vm.network "private_network",
:mac => "44:38:39:00:00:03",
:libvirt__tunnel_type => 'udp',
:libvirt__tunnel_local_ip => '127.0.0.1',
:libvirt__tunnel_local_port => "#{ 8002 + offset }",
:libvirt__tunnel_ip => '127.0.0.1',
:libvirt__tunnel_port => "#{ 9002 + offset }",
:libvirt__iface_name => 'swp2',
auto_config: false
# Run the Config specified in the Node Attributes
device.vm.provision :shell , privileged: false, :inline => 'echo "$(whoami)" > /tmp/normal_user'
# Install Rules for the interface re-map
device.vm.provision :shell , :inline => <<-delete_udev_directory
if [ -d "/etc/udev/rules.d/70-persistent-net.rules" ]; then
rm -rfv /etc/udev/rules.d/70-persistent-net.rules &> /dev/null
fi
rm -rfv /etc/udev/rules.d/70-persistent-net.rules &> /dev/null
delete_udev_directory
device.vm.provision :shell , :inline => <<-udev_rule
echo " INFO: Adding UDEV Rule: 44:38:39:00:00:01 --> swp1"
echo 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="44:38:39:00:00:01", NAME="swp1", SUBSYSTEMS=="pci"' >> /etc/udev/rules.d/70-persistent-net.rules
udev_rule
device.vm.provision :shell , :inline => <<-udev_rule
echo " INFO: Adding UDEV Rule: 44:38:39:00:00:03 --> swp2"
echo 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="44:38:39:00:00:03", NAME="swp2", SUBSYSTEMS=="pci"' >> /etc/udev/rules.d/70-persistent-net.rules
udev_rule
# Run Any Platform Specific Code and Apply the interface Re-map
# (may or may not perform a reboot depending on platform)
device.vm.provision :shell , :inline => $script
end
# DEFINE VM for leaf01 #####
config.vm.define "leaf01" do |device|
device.vm.hostname = "leaf01"
device.vm.box = "CumulusCommunity/cumulus-vx"
device.vm.box_version = "4.2.0"
device.vm.provider :libvirt do |v|
v.memory = 768
v.cpus = 2
end
# see note here: https://github.com/pradels/vagrant-libvirt#synced-folders
device.vm.synced_folder ".", "/vagrant", disabled: true
# NETWORK INTERFACES
# link for swp1 --> spine01:swp1
device.vm.network "private_network",
:mac => "44:38:39:00:00:02",
:libvirt__tunnel_type => 'udp',
:libvirt__tunnel_local_ip => '127.0.0.1',
:libvirt__tunnel_local_port => "#{ 9001 + offset }",
:libvirt__tunnel_ip => '127.0.0.1',
:libvirt__tunnel_port => "#{ 8001 + offset }",
:libvirt__iface_name => 'swp1',
auto_config: false
# link for swp2 --> leaf02:swp2
device.vm.network "private_network",
:mac => "44:38:39:00:00:05",
:libvirt__tunnel_type => 'udp',
:libvirt__tunnel_local_ip => '127.0.0.1',
:libvirt__tunnel_local_port => "#{ 8003 + offset }",
:libvirt__tunnel_ip => '127.0.0.1',
:libvirt__tunnel_port => "#{ 9003 + offset }",
:libvirt__iface_name => 'swp2',
auto_config: false
# link for swp3 --> leaf02:swp3
device.vm.network "private_network",
:mac => "44:38:39:00:00:07",
:libvirt__tunnel_type => 'udp',
:libvirt__tunnel_local_ip => '127.0.0.1',
:libvirt__tunnel_local_port => "#{ 8004 + offset }",
:libvirt__tunnel_ip => '127.0.0.1',
:libvirt__tunnel_port => "#{ 9004 + offset }",
:libvirt__iface_name => 'swp3',
auto_config: false
# Run the Config specified in the Node Attributes
device.vm.provision :shell , privileged: false, :inline => 'echo "$(whoami)" > /tmp/normal_user'
# Install Rules for the interface re-map
device.vm.provision :shell , :inline => <<-delete_udev_directory
if [ -d "/etc/udev/rules.d/70-persistent-net.rules" ]; then
rm -rfv /etc/udev/rules.d/70-persistent-net.rules &> /dev/null
fi
rm -rfv /etc/udev/rules.d/70-persistent-net.rules &> /dev/null
delete_udev_directory
device.vm.provision :shell , :inline => <<-udev_rule
echo " INFO: Adding UDEV Rule: 44:38:39:00:00:02 --> swp1"
echo 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="44:38:39:00:00:02", NAME="swp1", SUBSYSTEMS=="pci"' >> /etc/udev/rules.d/70-persistent-net.rules
udev_rule
device.vm.provision :shell , :inline => <<-udev_rule
echo " INFO: Adding UDEV Rule: 44:38:39:00:00:05 --> swp2"
echo 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="44:38:39:00:00:05", NAME="swp2", SUBSYSTEMS=="pci"' >> /etc/udev/rules.d/70-persistent-net.rules
udev_rule
device.vm.provision :shell , :inline => <<-udev_rule
echo " INFO: Adding UDEV Rule: 44:38:39:00:00:07 --> swp3"
echo 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="44:38:39:00:00:07", NAME="swp3", SUBSYSTEMS=="pci"' >> /etc/udev/rules.d/70-persistent-net.rules
udev_rule
# Run Any Platform Specific Code and Apply the interface Re-map
# (may or may not perform a reboot depending on platform)
device.vm.provision :shell , :inline => $script
end
##### DEFINE VM for leaf02 #####
config.vm.define "leaf02" do |device|
device.vm.hostname = "leaf02"
device.vm.box = "CumulusCommunity/cumulus-vx"
device.vm.box_version = "4.2.0"
device.vm.provider :libvirt do |v|
v.memory = 768
v.cpus = 2
end
# see note here: https://github.com/pradels/vagrant-libvirt#synced-folders
device.vm.synced_folder ".", "/vagrant", disabled: true
# NETWORK INTERFACES
# link for swp1 --> spine01:swp2
device.vm.network "private_network",
:mac => "44:38:39:00:00:04",
:libvirt__tunnel_type => 'udp',
:libvirt__tunnel_local_ip => '127.0.0.1',
:libvirt__tunnel_local_port => "#{ 9002 + offset }",
:libvirt__tunnel_ip => '127.0.0.1',
:libvirt__tunnel_port => "#{ 8002 + offset }",
:libvirt__iface_name => 'swp1',
auto_config: false
# link for swp2 --> leaf01:swp2
device.vm.network "private_network",
:mac => "44:38:39:00:00:06",
:libvirt__tunnel_type => 'udp',
:libvirt__tunnel_local_ip => '127.0.0.1',
:libvirt__tunnel_local_port => "#{ 9003 + offset }",
:libvirt__tunnel_ip => '127.0.0.1',
:libvirt__tunnel_port => "#{ 8003 + offset }",
:libvirt__iface_name => 'swp2',
auto_config: false
# link for swp3 --> leaf01:swp3
device.vm.network "private_network",
:mac => "44:38:39:00:00:08",
:libvirt__tunnel_type => 'udp',
:libvirt__tunnel_local_ip => '127.0.0.1',
:libvirt__tunnel_local_port => "#{ 9004 + offset }",
:libvirt__tunnel_ip => '127.0.0.1',
:libvirt__tunnel_port => "#{ 8004 + offset }",
:libvirt__iface_name => 'swp3',
auto_config: false
# Run the Config specified in the Node Attributes
device.vm.provision :shell , privileged: false, :inline => 'echo "$(whoami)" > /tmp/normal_user'
# Install Rules for the interface re-map
device.vm.provision :shell , :inline => <<-delete_udev_directory
if [ -d "/etc/udev/rules.d/70-persistent-net.rules" ]; then
rm -rfv /etc/udev/rules.d/70-persistent-net.rules &> /dev/null
fi
rm -rfv /etc/udev/rules.d/70-persistent-net.rules &> /dev/null
delete_udev_directory
device.vm.provision :shell , :inline => <<-udev_rule
echo " INFO: Adding UDEV Rule: 44:38:39:00:00:04 --> swp1"
echo 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="44:38:39:00:00:04", NAME="swp1", SUBSYSTEMS=="pci"' >> /etc/udev/rules.d/70-persistent-net.rules
udev_rule
device.vm.provision :shell , :inline => <<-udev_rule
echo " INFO: Adding UDEV Rule: 44:38:39:00:00:06 --> swp2"
echo 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="44:38:39:00:00:06", NAME="swp2", SUBSYSTEMS=="pci"' >> /etc/udev/rules.d/70-persistent-net.rules
udev_rule
device.vm.provision :shell , :inline => <<-udev_rule
echo " INFO: Adding UDEV Rule: 44:38:39:00:00:08 --> swp3"
echo 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="44:38:39:00:00:08", NAME="swp3", SUBSYSTEMS=="pci"' >> /etc/udev/rules.d/70-persistent-net.rules
udev_rule
# Run Any Platform Specific Code and Apply the interface Re-map
# (may or may not perform a reboot depending on platform)
device.vm.provision :shell , :inline => $script
end
end