[FIX] script todo: wait for cloud-init before install (Arch pacman lock)

The Arch install failed at once: "error: failed to synchronize all
databases (unable to lock database)" then "reflector: command not
found". Cause: cloud-init was still running its own pacman (installing
qemu-guest-agent/openssh) and held /var/lib/pacman/db.lck when our
bootstrap started, so every pacman call failed and reflector never got
installed.

Fix: the remote install now waits for cloud-init to finish first
("cloud-init status --wait", 15 min timeout) before touching any package
manager — this releases the apt/dnf/pacman lock cloud-init holds during
its package stage (helps all distros). For Arch, also drop a stale
db.lck when no pacman is actually running. Verified live: cloud-init
done, no lock, reflector + refresh + curl/git/make all succeed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Mathieu Benoit 2026-07-28 06:27:15 +00:00
parent 7a001a9b84
commit 137f4245ec

View file

@ -1673,6 +1673,13 @@ class TODO:
puis clone + make install_os + make install_odoo_18)."""
return (
"set -e; "
# Attendre la FIN de cloud-init : pendant sa phase « paquets » il
# tient le verrou apt/dnf/pacman -> sinon « unable to lock
# database » (Arch) / « Could not get lock » (apt). timeout pour ne
# pas bloquer indéfiniment si cloud-init traîne.
"command -v cloud-init >/dev/null 2>&1 && "
"sudo timeout 900 cloud-init status --wait >/dev/null 2>&1 "
"|| true; "
# Outils d'amorçage (absents des images cloud minimales) : curl,
# git, make. Chaque branche RAFRAÎCHIT d'abord les dépôts pour que
# la VM soit la plus rapide possible (miroirs à jour / les plus
@ -1693,6 +1700,10 @@ class TODO:
"sudo dnf install -y --refresh $PKGS || "
"{ sudo dnf clean all; sudo dnf install -y --refresh $PKGS; }; "
"elif command -v pacman >/dev/null 2>&1; then "
# Verrou pacman périmé (cloud-init interrompu) : le retirer SEULEMENT
# si aucun pacman ne tourne, sinon on attend qu'il se libère.
"pgrep -x pacman >/dev/null 2>&1 "
"|| sudo rm -f /var/lib/pacman/db.lck; "
# Arch : reflector sélectionne les miroirs HTTPS les plus rapides,
# puis rafraîchit la base et installe.
"sudo pacman -Sy --needed --noconfirm reflector || true; "