@olivierlambert That could be cleaned up a bit; I wouldn't just copy and paste that. I just hope my sloppy notes help someone else. I spent a few hours figuring this out lol.
Posts
-
RE: Ubuntu 22.04.5 custom template - additional steps missing from documentation
-
Ubuntu 22.04.5 custom template - additional steps missing from documentation
If you are trying to create an Ubuntu template and are having trouble on XCP-NG 8.3 (some or all probably applies to previous versions), keep reading.
I followed the documentation titled: Create and use custom XCP-NG templates: a guide for Ubuntu
At the following link:
https://docs.xcp-ng.org/guides/create-use-custom-xcpng-ubuntu-templates/I downloaded the 22.04.5 server iso (barely newer than the version on this site). I used the minimal install. The process did not work 100% and had 3 issues with the official documentation:
-
The machine-ID does not change after creating a new VM from the template
-
When you go to clone the template, it will not apply the Network Config - it will be on DHCP
-
The YAML format for "Network Config" is incorrect
Here is a summary of the steps from the official documentation above, which I did and are mostly necessary (some of these files/directories do not exist, but still OK to run this all to be sure):
sudo apt update && sudo apt upgrade sudo apt install xe-guest-utilities sudo apt install cloud-init sudo apt install cloud-initramfs-growroot sudo dpkg-reconfigure cloud-init
NOTE: here you want to select NoCloud, ConfigDrive, and OpenStack
sudo rm -f /etc/cloud/cloud.cfg.d/99-installer.cfg sudo rm -f /etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg sudo rm -rf /var/lib/cloud/instance sudo rm -f /etc/netplan/00-installer-config.yaml
I had to run the following in addition to what was mentioned in the documentation to get the template to generate a new machine-id, to get it to apply the static IP address when creating a VM from the template, and also clear the cloud-init logs for further troubleshooting:
sudo rm -rf /var/lib/cloud/instances /var/lib/cloud/instance sudo rm -rf /var/log/cloud-init.log /var/log/cloud-init* sudo rm -f /etc/netplan/50-cloud-init.yaml sudo rm -f /etc/cloud/cloud.cfg.d/90-installer-network.cfg sudo truncate -s 0 /etc/machine-id
Then you will shutdown and create the template.
You want to use this format for the "Network Config" YAML:
#cloud-config network: version: 2 ethernets: eth0: dhcp4: false addresses: - 10.0.2.6/27 gateway4: 10.0.2.1 nameservers: addresses: - 10.0.2.1 - 1.1.1.1
Make sure your IP is in CIDR notation.
If you have any trouble, in /var/log you want to look through the cloud-init.log to start, and there is another cloud-init log in there.
-
-
RE: "No Stats" Issue
In case anyone comes across the "no stats" issue, I was able to solve my problem. I fully updated all my hosts in the pool and also XO. Still, I got "no stats" for the hosts and VMs.
The issue was I had recently set the "default migration network" and "backup network" for the pool. If you are having this issue, go to home>pools, select the pool having the issue, select "advanced", then scroll to the bottom under "Misc". I set them both back to "none" and it works now.
What clued me in was checking the logs (in XO - go to settings>logs), and I saw XO was trying to access my /31 subnet for backup/management traffic between my hosts (this is a P2P connection):
I am guessing that changing this also means XO will attempt to look at these interfaces for all management traffic and stats, and since there was no route to my /31 from my LAN to XO, it couldn't get the data.
I am sure I can get both working, but for now, I will just wait the extra 10 minutes or so for my backups and migrations to complete over gigabit (this is a home lab).
Coming from VMWare, maybe there should be a note about this on the GUI? Also coming from VMware - I want to thank the team (@olivierlambert) for doing a fantastic job; XCP-NG and XO has been rock solid in my homelab on random hardware that I have laying around. This issue was very minor, and maybe this was completely my mistake.