-
Notifications
You must be signed in to change notification settings - Fork 103
Build custom FRR Vagrant boxes with preinstalled FRR package #3036
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| (build-frr)= | ||
| # Building an FRRouting Libvirt Box | ||
|
|
||
| By default, _netlab_ uses Debian Vagrant boxes to start FRRouting virtual machines. The Debian boxes do not contain the FRR package (or a few other packages). These packages are installed whenever a lab starts, resulting in significantly longer start times. | ||
|
|
||
| You can use the **netlab libvirt package** command to build a custom FRRouting Vagrant box: | ||
|
|
||
| * Use the **netlab show images -d frr** to find the Debian release we use for FRR virtual machines | ||
| * Download the latest relevant Debian **-generic-amd64.qcow2** image from [Debian Official Cloud Images](https://cloud.debian.org/images/cloud/) (the Bookworm images are [here](https://cloud.debian.org/images/cloud/bookworm/latest/)) into an empty directory | ||
| * Execute **netlab libvirt package frr _img-file-name_** and follow the instructions | ||
|
|
||
| ```{warning} | ||
| If you're using a *netlab* release older than 1.8.2, or if you're using a Linux distribution other than Ubuntu, please [read the box-building caveats first](libvirt-box-caveats.md). | ||
| ``` | ||
|
|
||
| **netlab libvirt package** starts the Debian VM and uses **cloud-init** to configure it, install additional software packages, and shut it down. | ||
|
|
||
| All you have to do is identify the FRR version that was installed on the VM and pass it to the **netlab libvirt package** command when it asks for the box version. Scroll through the printouts and find the end-of-installation message that should look similar to this: | ||
|
|
||
| ``` | ||
| [ 21.094634] cloud-init[500]: Installation complete | ||
| [ 21.095042] cloud-init[500]: ================================= | ||
| [ 21.100452] cloud-init[500]: FRR version installed: 10.5.1 | ||
| [ 21.100844] cloud-init[500]: ================================= | ||
| ``` | ||
|
|
||
| ```{tip} | ||
| If the installation process fails, the VM remains running. You can log in as user **vagrant** (password **vagrant**) and investigate the cause of the error (or [open an issue](https://github.com/ipspace/netlab/issues/new/choose)). To disconnect from the VM, use the **virsh** disconnect sequence (usually `Ctrl-]`). | ||
| ``` | ||
|
|
||
| After finishing the box-building process, the **netlab libvirt package** command tells you how to use the custom box in a lab topology or as a default FRR box: | ||
|
|
||
| ``` | ||
| You created a custom Vagrant box. To use this box in a lab topology, add the | ||
| following setting to the lab topology: | ||
|
|
||
| defaults.devices.frr.libvirt.image: netlab/frr | ||
|
|
||
| Alternatively, use the "netlab defaults" command to set the custom box as the | ||
| directory-, project- or user default, for example: | ||
|
|
||
| netlab defaults devices.frr.libvirt.image=netlab/frr | ||
| ``` | ||
|
|
||
| Finally, use the **netlab libvirt remove --box netlab/frr** command if you want to remove the custom FRR Vagrant box. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| <domain type='kvm'> | ||
| <name>vm_box</name> | ||
| <memory unit='MiB'>1024</memory> | ||
| <currentMemory unit='MiB'>1024</currentMemory> | ||
| <vcpu placement='static'>1</vcpu> | ||
| <resource> | ||
| <partition>/machine</partition> | ||
| </resource> | ||
| <os> | ||
| <type arch='x86_64'>hvm</type> | ||
| <boot dev='hd'/> | ||
| </os> | ||
| <features> | ||
| <acpi/> | ||
| <apic/> | ||
| <pae/> | ||
| </features> | ||
| <cpu mode='host-model' check='partial'/> | ||
| <clock offset='utc' /> | ||
| <on_poweroff>destroy</on_poweroff> | ||
| <on_reboot>restart</on_reboot> | ||
| <on_crash>restart</on_crash> | ||
| <pm> | ||
| <suspend-to-mem enabled='no'/> | ||
| <suspend-to-disk enabled='no'/> | ||
| </pm> | ||
| <devices> | ||
| <emulator>/usr/bin/qemu-system-x86_64</emulator> | ||
| <disk type='file' device='disk'> | ||
| <driver name='qemu' type='qcow2'/> | ||
| <source file='{{ user.cwd }}/vm.qcow2'/> | ||
| <backingStore /> | ||
| <target dev='vda' bus='virtio'/> | ||
| <alias name='virtio-disk0'/> | ||
| <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> | ||
| </disk> | ||
| <disk type='file' device='cdrom'> | ||
| <driver name='qemu' type='raw'/> | ||
| <source file='{{ user.cwd }}/bootstrap.iso' index='1'/> | ||
| <backingStore/> | ||
| <target dev='hda' bus='ide'/> | ||
| <readonly/> | ||
| <alias name='ide0-0-0'/> | ||
| <address type='drive' controller='0' bus='0' target='0' unit='0'/> | ||
| </disk> | ||
| <controller type='usb'/> | ||
| <controller type='pci' index='0' model='pci-root'/> | ||
| <controller type='ide' index='0'> | ||
| <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> | ||
| </controller> | ||
| <interface type='network'> | ||
| <source network='vagrant-libvirt'/> | ||
| <model type='virtio'/> | ||
| </interface> | ||
| <console type='pty'> | ||
| <target type='serial' port='0'/> | ||
| </console> | ||
| <input type='mouse' bus='ps2'/> | ||
| <input type='keyboard' bus='ps2'/> | ||
| <memballoon model='virtio'/> | ||
| </devices> | ||
| </domain> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| local-hostname: frr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| #cloud-config | ||
| hostname: frr | ||
| create_hostname_file: true | ||
| fqdn: lab.local | ||
| ssh_pwauth: true | ||
| disable_root: false | ||
| system_info: | ||
| default_user: | ||
| name: vagrant | ||
|
|
||
| network: | ||
| version: 2 | ||
| ethernets: | ||
| eth0: | ||
| dhcp4: true | ||
|
|
||
| users: | ||
| - name: vagrant | ||
| groups: [sudo] | ||
| shell: /bin/bash | ||
| sudo: ['ALL=(ALL) NOPASSWD:ALL'] | ||
| ssh_authorized_keys: | ||
| - ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key | ||
| - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIN1YdxBpNlzxDqfJyw/QKow1F+wvG9hXGoqiysfJOn5Y vagrant insecure public key | ||
|
|
||
| chpasswd: | ||
| expire: false | ||
| list: | | ||
| root:vagrant | ||
| vagrant:vagrant | ||
|
|
||
| bootcmd: | ||
| - sed -i 's/^GRUB_CMDLINE_LINUX=.*/GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200 net.ifnames=0 biosdevname=0"/' /etc/default/grub | ||
| - update-grub | ||
|
|
||
| runcmd: | ||
| - [ sh, "/etc/netlab-install.sh" ] | ||
|
|
||
| write_files: | ||
| - path: /etc/netlab-install.sh | ||
| permissions: '0755' | ||
| content: | | ||
| #!/bin/bash | ||
| set -e | ||
| export DEBIAN_FRONTEND=noninteractive | ||
| echo "Installing ifupdown, GPG, curl, and iproute2" | ||
| apt-get update -qq >/dev/null | ||
| apt-get install -qq ifupdown curl gnupg iproute2 >/dev/null | ||
| echo "Installing FRR" | ||
| curl -s https://deb.frrouting.org/frr/keys.asc >/etc/apt/trusted.gpg.d/frr.asc | ||
| FRRVER="frr-stable" | ||
| echo deb https://deb.frrouting.org/frr $(lsb_release -s -c) $FRRVER > /etc/apt/sources.list.d/frr.list | ||
| apt-get update -qq >/dev/null | ||
| apt-get install -qq frr frr-pythontools bridge-utils ethtool >/dev/null | ||
| systemctl disable systemd-networkd --now | ||
| systemctl mask systemd-networkd | ||
| systemctl disable systemd-resolved --now | ||
| systemctl mask systemd-resolved | ||
| systemctl enable networking --now | ||
| echo "Installation complete" | ||
| echo | ||
| echo | ||
| echo "=================================" | ||
| echo "FRR version installed: $(dpkg-query -W -f='${Version}\n' frr | cut -d- -f1)" | ||
| echo "=================================" | ||
| echo | ||
| echo | ||
| shutdown -P now | ||
| - path: /etc/network/interfaces | ||
| content: | | ||
| # interfaces(5) file used by ifup(8) and ifdown(8) | ||
| # Include files from /etc/network/interfaces.d: | ||
| source-directory /etc/network/interfaces.d | ||
|
|
||
| # The loopback network interface | ||
| auto lo | ||
| iface lo inet loopback | ||
|
|
||
| # The primary network interface | ||
| allow-hotplug eth0 | ||
| iface eth0 inet dhcp | ||
| - path: /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg | ||
| content: | | ||
| network: {config: disabled} | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.