From dc9dfa577979fc41ba16192cb181b8dfaa6ed9ab Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Sun, 19 Jul 2026 09:33:33 +0000 Subject: [PATCH] [FIX] script qemu: make Debian VMs usable (virtio seed + sudo group) Debian VMs came up with no configured user, no hostname and no SSH key, so neither the console (erplibre/erplibre) nor SSH worked. Two causes, found via the guest cloud-init.log: 1. The NoCloud seed was attached as a CD-ROM. Debian's initramfs does not load the CD driver (sr_mod) at the init-local stage, so the "cidata" volume was invisible and cloud-init fell back to an empty DMI seed (Ubuntu tolerates the CD). Attach the seed as a read-only virtio disk instead: virtio-blk is in the initramfs, the label is seen immediately, and the user-data is applied. Works for Ubuntu too. 2. The user was added to group "admin", which does not exist on Debian (it does on Ubuntu) -> useradd failed and the user was never created. Use "sudo" (present on both) instead. Validated end to end: Debian 12 and Ubuntu 24.04 both get the erplibre user (in sudo), the hostname, console login erplibre/erplibre and SSH by key. Co-Authored-By: Claude Opus 4.8 (1M context) --- script/qemu/deploy_qemu.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/script/qemu/deploy_qemu.py b/script/qemu/deploy_qemu.py index 8d39065..18d33e0 100755 --- a/script/qemu/deploy_qemu.py +++ b/script/qemu/deploy_qemu.py @@ -740,7 +740,10 @@ def build_cloud_config( "users:", f" - name: {args.user}", " sudo: ALL=(ALL) NOPASSWD:ALL", - " groups: users, admin", + # « sudo » existe sur Debian ET Ubuntu ; « admin » n'existe PAS sur + # Debian -> useradd -G ...,admin échoue et l'utilisateur n'est jamais + # créé (login/clé SSH KO). C'était la cause du « Debian ne marche pas ». + " groups: users, sudo", " shell: /bin/bash", " lock_passwd: false" if pw_hash else " lock_passwd: true", ] @@ -945,8 +948,13 @@ def virt_install( "--import", "--disk", f"path={disk},format=qcow2,bus=virtio", + # Seed cloud-init attaché comme DISQUE virtio en lecture seule (et non + # en CD-ROM) : le pilote virtio-blk est dans l'initramfs, donc le + # volume « cidata » est visible dès init-local et cloud-init le lit. + # En CD-ROM, l'initramfs Debian ne charge pas sr_mod à temps -> le + # seed n'est pas vu et rien ne s'applique (Ubuntu, lui, tolère le CD). "--disk", - f"path={seed},device=cdrom", + f"path={seed},readonly=on,bus=virtio", "--osinfo", osinfo, "--network",