References
- https://techviewleo.com/how-to-configure-network-bonding-on-ubuntu/
- https://www.linuxtechi.com/how-to-install-kvm-on-ubuntu-22-04/
- https://linuxconfig.org/how-to-create-and-manage-kvm-virtual-machines-from-cli
- https://computingforgeeks.com/how-to-run-plex-media-server-in-docker-containers/
- https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html
The computer environment for this task has the following resources:
- 1 x Dell PowerEdge R610 server with 4 x 1GB network ports
- Laptop running MX Linux 21 (this will be the ansible control node)
- Media Center (will use this as a git ssh server)
Initially a vanilla install (from USB flash drive) of Ubuntu 22.04 server was performed. Afterwords, a Linux bond was created, utilizing network devices eno4 and eno1. eno2 was used temporarily for this configuration, as the work was performed remotely instead of in front of the machine.
configure_network_bonding
To configure the network bond:
modprobe bondinglsmod |grep bonding ## used to validate bond
echo 'bonding' | sudo tee -a /etc/modules ## set to autostart on server boot
Currently eno1, eno2 and eno4 have been doled out DHCP addresses. So we’ll change the configuration for eno1 and eno4, as those will become the bond members. So we’ll have to bring them down first.
ifconfig eno1 down && ifconfig eno4 down
Next we’ll create a Linux network bond with the mode 0 Round-Robin policy, aka ‘balance-rr’, and then add the two ethernet interfaces as members.
sudo ip link add bond0 type bond mode balance-rr
sudo ip link set eno1 master bond0
sudo ip link set eno4 master bond0
sudo ip link ## validate
Assuming all went well with the Linux bond creation, we are going to make it permanent in the next steps.
sudo vim /etc/netplan/00-installer-config.yaml
network:
ethernets:
en01:
dhcp4: no
eno2:
dhcp4: yes
eno3:
dhcp4: yes
eno4:
dhcp4: no
version: 2
bonds:
bond0:
interfaces: [eno1, eno4]
addresses: [192.168.205.100/24]
gateway4: 192.186.205.1
parameters:
mode: active-backup
transmit-hash-policy: layer3+4
mii-monitor-interval: 1
nameservers:
addresses:
– “8.8.8.8”
– “1.1.1.1”
NOTE: If you’re devices, IPs are different, feel free to modify them to suit your environment.
Next bring the interfaces down: ifconfig bond0 down ; ifconfig eno1 down ; ifconfig eno4 down
start them up with: sudo netplan apply
start the network bond: sudo ifconfig bond0 up
validate with: sudo ifconfig bond0
Detailed networking information is also available with: sudo cat /proc/net/bonding/bond0
The bond’s fail-over can be tested by either doing an ifconfig DEVICE down, disabling the port from the network switch side, or physically removing the network cable from the appropriate network interface.
Usually it’s a good plan to monitor the logs with: sudo tail -f /var/log/syslog to see when the ethernet member is offline / online and the status of the bond. Repeat for other side (once first side has recovered).
Server Install
Perform a vanilla Ubuntu server 22.04 install. In my case, I downloaded the media and put it on an USB flash drive, then done the installation from there. As we will be manipulating VMs with KVM, there is an ansible module in the community that can be utilized for that. So let’s install that on our workstation with:ansible-galaxy collection install community.libvirt
Our next task will be copying over our ssh public key. Disabling password authentication is typically done next.
One could upload their ssh public key with something like: ssh-copy-id -i ~/.ssh/id_rsa user@serverip and validate it works by ssh serverip or ssh user@serverip if it’s a different user than the one currently being used on your workstation. Ensure you copy over the ssh key’s to the media center and the home lab server.
Now some things are going to be automated for this lab configuration using the configuration management tool ansible. However, I would also like to put the directory structure that will contain all of our ansible data under git control. Thus, we’ll connect to the media center machine first, setup an empty directory, and put that under git control.
ssh mc
mkdir git
git init --bare ansible
Next, we’ll grab that ’empty’ project, clone it to our ansible control node, and populate that with our ansible playbooks, inventories, etc… and keep it all under git control. So on the ansible control node, let’s clone that empty project: cd ~ && git clone ssh://USER@mc/home/USER/git/ansible
- USER => replace that with your actual username
- mc => that is the hostname of the media center. replace this to match your configuration.
ansible_install
Next, is the ansible install process. That varies alot, so refer to intro installation reference at the top of this document.
Once ansible is installed, we’re going to grab a collection which we will utilize later for managing KVM vms.
sudo ansible-galaxy collection install community.libvirt
setup an ansible role for kvm
Create a role and populate it with some defaults:cd ~/ansible && ansible-galaxy role init kvm
At any point, you can run some standard git commands to push your changes to the git repository. Some global changes can be made with: git config global –edit
git status
git add
git commmit -m 'initial commit'
git push
As KVM images can get quite large, we’re going to manually create a new LV (non-raid) for the libvirt stuff. This of course could be automated later with ansible if so desired.
export myvg=vgs --noheadings
lvcreate -L 40G -n images $myvg
mkfs.xfs /dev/mapper/ubuntu--vg-images
mount /dev/mapper/ubuntu--vg-images /var/lib/libvirt/images/
run a sudo blkid to get the UUID and then put that mount in the /etc/fstab