From c3291c3254f5f475dc9f48bfd82426cef96a8ee6 Mon Sep 17 00:00:00 2001 From: Stephen L Arnold Date: Thu, 16 Apr 2026 10:18:31 -0700 Subject: [PATCH 1/2] chg: cleanup OS names and leave a comment, add README note Signed-off-by: Stephen L Arnold --- README.md | 6 ++++++ templates/rockylinux10.ini | 5 +++-- templates/rockylinux9.ini | 4 ++-- templates/ubuntu26.04.ini | 1 + 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f497ae9..449df91 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,12 @@ For non-root usage, add your user to the `libvirt` and `kvm` groups: sudo usermod -aG libvirt,kvm $USER ``` +> [!IMPORTANT] +> The OS distro names are only as current as the version of `osinfo-db` +> installed in your environment. If the name is not found, eg, `rocky10`, +> then you need to edit the template file and change the OSVARIANT to +> `unknown` in order to install the desired OS version. + --- ## **Configuration** diff --git a/templates/rockylinux10.ini b/templates/rockylinux10.ini index fe11faa..0b1fcea 100644 --- a/templates/rockylinux10.ini +++ b/templates/rockylinux10.ini @@ -1,4 +1,5 @@ URL=https://dl.rockylinux.org/pub/rocky/10/images/x86_64/Rocky-10-GenericCloud-Base.latest.x86_64.qcow2 -SOURCE=source-rockylinux10.img -OSVARIANT=rockylinux10 +SOURCE=source-rocky10.img +OSVARIANT=rocky10 +#OSVARIANT=rocky-unknown CONSOLE="pty,target_type=virtio" diff --git a/templates/rockylinux9.ini b/templates/rockylinux9.ini index b2dc3cf..d98d008 100644 --- a/templates/rockylinux9.ini +++ b/templates/rockylinux9.ini @@ -1,4 +1,4 @@ URL=https://dl.rockylinux.org/pub/rocky/9/images/x86_64/Rocky-9-GenericCloud-Base.latest.x86_64.qcow2 -SOURCE=source-rockylinux9.img -OSVARIANT=rockylinux9 +SOURCE=source-rocky9.img +OSVARIANT=rocky9 CONSOLE="pty,target_type=virtio" diff --git a/templates/ubuntu26.04.ini b/templates/ubuntu26.04.ini index 0562bf0..d9a5bc5 100644 --- a/templates/ubuntu26.04.ini +++ b/templates/ubuntu26.04.ini @@ -1,4 +1,5 @@ URL=https://cloud-images.ubuntu.com/resolute/current/resolute-server-cloudimg-amd64.img SOURCE=source-ubuntu26.04.img OSVARIANT=ubuntu26.04 +#OSVARIANT=unknown CONSOLE="pty,target_type=virtio" From 3a4c1f27661949adb88f165c08b8dcdd9398785c Mon Sep 17 00:00:00 2001 From: Stephen L Arnold Date: Thu, 16 Apr 2026 10:24:05 -0700 Subject: [PATCH 2/2] chg: replace the wait arg with wait-for-IP function Signed-off-by: Stephen L Arnold --- bin/launch-vm.sh | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/bin/launch-vm.sh b/bin/launch-vm.sh index 19a9d69..415c303 100755 --- a/bin/launch-vm.sh +++ b/bin/launch-vm.sh @@ -201,23 +201,57 @@ vm-setup() { exit 1 fi - virt-install \ + virt-install --import \ --name "${VMNAME}" \ --memory "${VMEM}" \ --vcpus "${VCPUS}" \ + --cpu host-model \ --disk "vol=${VMPOOL}/${VMVOL},bus=virtio,format=qcow2" \ --os-variant "${OSVARIANT}" \ --network "network=${NETWORK},model=virtio" \ --virt-type kvm \ - --import \ --cloud-init "user-data=${CLOUD_CONFIG_FILE}" \ - --wait \ --noautoconsole \ --console "${CONSOLE:-}" \ --video none \ --qemu-commandline="-smbios type=1,serial=ds=nocloud;h=${VMNAME}.${DOMAIN}" } +get-vminfo() { + IP=${IP:-} + timeout=60 # seconds + if [[ ! -n "$IP" ]]; then + echo "Waiting for $VMNAME IP address..." + for ((i = 0; i < timeout; i++)); do + DOM=$(virsh -q domifaddr "$VMNAME") + read -ra arr <<<"$DOM" + if [[ -n "${arr[@]}" ]]; then + IP="${arr[3]%/*}" + fi + + if [[ -n "$IP" ]]; then + break + fi + sleep 1 + done + fi + + if [[ -n "$IP" ]]; then + echo "" + echo "SSH to ${VMNAME}:" + echo " ssh ${IP}" + echo " ssh ubuntu@${IP}" + echo "" + echo "Checking for ${IP} in known_hosts file" + grep -q ${IP} ${HOME}/.ssh/known_hosts && + echo "Found entry for ${IP}. Removing" && + (sed --in-place "/^${IP}/d" ~/.ssh/known_hosts) || + echo "No entries found for ${IP}" + else + echo "Timed out waiting for DHCP lease" + fi +} + # ------------------------------------------------------------------------- # Main Execution Flow # ------------------------------------------------------------------------- @@ -229,3 +263,4 @@ import-base-volume clone-base resize-clone vm-setup +get-vminfo