diff --git a/_posts/2023/2023-02-15-cobbler-inside-libvirt-1.md b/_posts/2023/2023-02-15-cobbler-inside-libvirt-1.md new file mode 100644 index 00000000..f2ff352d --- /dev/null +++ b/_posts/2023/2023-02-15-cobbler-inside-libvirt-1.md @@ -0,0 +1,129 @@ +--- +layout: post +title: Cobbler inside libvirt (1) +author: Enno +summary: Cobbler inside libvirt with a private libvirt network +--- + +The last blog post that was neither a roadmap update or a release announcement was in december of 2020. Thus it is time +to give you guys a new guide! + +This time we will together explore how to use Cobbler to enable a libvirt internal network to boot over the network. +The guide will assume you have a running host OS and libvirt installed and running already. As a guest OS I will use +openSUSE Tumbleweed but any other guest OS should work equally good. + +In case you have libvirt not installed please consult your OS vendors resources to do so. A few examples: + +- [openSUSE](https://doc.opensuse.org/documentation/leap/virtualization/html/book-virtualization/part-virt-libvirt.html) +- [Fedora](https://developer.fedoraproject.org/tools/virtualization/installing-libvirt-and-virt-install-on-fedora-linux.html) +- [Ubuntu](https://ubuntu.com/server/docs/virtualization-libvirt) + +Note: + +> There will be a second part of this guide where we will utilize a network bridge to also boot real hardware with our +> VM based Cobbler setup. + +Information: + +> Depending on your setup you may need to prefix the `virsh` and other commands with `sudo`. + +1. Create libvirt network for Cobbler (don't use the network `default`). + ```xml + xml + cobbler + 6b7f4f36-7895-4b74-8be6-dfa4b2b84500 + + + + + + + + + ``` +2. Download the openSUSE Tumbleweed ISO and move it to your desired libvirt storage pool (below I show the default + location): + ``` + wget https://download.opensuse.org/tumbleweed/iso/openSUSE-Tumbleweed-NET-x86_64-Current.iso + mv openSUSE-Tumbleweed-NET-x86_64-Current.iso /var/lib/libvirt/images + ``` +3. Setup the guest. An example for a guide can be found [in the openSUSE Documentation](https://doc.opensuse.org/documentation/leap/virtualization/html/book-virtualization/cha-kvm-inst.html#sec-libvirt-inst-vmm). +4. Login into the guest either via SSH or if you are using `virt-manager` using the GUI. +5. `zypper in cobbler` (atm 3.3.3) +6. Shutdown the VM from the host + ``` + virsh shutdown "" + ``` + or if you are logged into the guest use + ``` + systemctl poweroff + ``` +7. Add a second network to the guest. Use the network defined in step 1. +8. Start the VM again use the UI of `virt-manager` or use + ``` + virsh start "" + ``` +9. Log into the VM after it started using SSH (easier to copy & paste between host and guest). + ``` + ssh root@192.168.122.xxx + ``` +10. Setup the secondary network interface that is inside the network that Cobbler is managing: + ``` + ip a add 10.17.3.2/24 dev eth1 + ip link set dev eth1 up + ip route add 10.17.3.0/24 via 10.17.3.1 + ``` + You will need to adjust the name of the interface `eth1` to the interface that doesn't belong to the default NAT + network. +11. Edit Cobbler settings to match IP on guest (and thus subnet): + ```yml + server: 10.17.3.2 + next_server_v4: 10.17.3.2 + manage_dhcp: true + manage_dhcp_v4: true + ``` +12. Restart Cobbler + ``` + systemctl restart cobblerd + ``` +13. Download the openSUSE Leap image (or any other full DVD ISO) inside the Cobbler VM: + ``` + wget https://download.opensuse.org/distribution/leap/15.4/iso/openSUSE-Leap-15.4-DVD-x86_64-Media.iso + ``` +14. Mount the ISO to a reasonable directory: + ``` + mkdir -p /mnt/cobbler-isos/leap-15-4 + mount -o loop /root/openSUSE-Leap-15.4-DVD-x86_64-Media.iso /mnt/cobbler-isos/leap-15-4 + ``` +15. Use `cobbler import` to automate setting up a distro and profile: + ``` + cobbler import --name="openSUSE-Leap-15-4" --path="/mnt/cobbler-isos/leap-15-4/" + ``` +16. Setup an emtpy VM - no installation media required. Make note of the MAC address of the VM. +17. Add the system to Cobbler: + ``` + cobbler system add --name="testsystem" --profile="openSUSE-Leap-15-4-x86_64" --mac="" --ip="10.17.3.20" + ``` +18. Generate the bootloaders and sync them into the TFTP Tree + ``` + cobbler mkloaders && cobbler sync + ``` +19. Profit + +To clean up after your experiments there are only a couple of commands needed: + +``` +virsh destroy && virsh destroy && virsh net-destroy cobbler +``` + +Further topics: + +- Write autoinstall snippets for your setups +- Setup Windows Guests +- Don't forget to set netboot_enabled to `False` + +--- + +P.S.: In case your find typos and/or grammar mistakes just +[open an Issue](https://github.com/cobbler/cobbler.github.io/issues/new) or +[open a PR](https://github.com/cobbler/cobbler.github.io/compare). diff --git a/_posts/2023/2023-02-16-cobbler-inside-libvirt-2.md b/_posts/2023/2023-02-16-cobbler-inside-libvirt-2.md new file mode 100644 index 00000000..d207a0b7 --- /dev/null +++ b/_posts/2023/2023-02-16-cobbler-inside-libvirt-2.md @@ -0,0 +1,27 @@ +--- +layout: post +title: Cobbler inside libvirt (2) +author: Enno +summary: Cobbler inside libvirt with a network bridge +--- + +- Assume part 1 is read +- Assume DHCP is handled externally +- Setup libvirt bridge +- Install guest OS +- Install Cobbler +- Do settings to match IP range +- Restart Cobbler +- Add SSH keys +- Login from host via SSH +- wget leap DVD ISO +- cobbler import +- cobbler system add +- cobbler sync +- Setup emtpy VM with bridge network + +--- + +P.S.: In case your find typos and/or grammar mistakes just +[open an Issue](https://github.com/cobbler/cobbler.github.io/issues/new) or +[open a PR](https://github.com/cobbler/cobbler.github.io/compare).