two-images: rocky10, profils NM de cloud-init nommés par interface #1
All checks were successful
Tests / check (push) Successful in 38s
All checks were successful
Tests / check (push) Successful in 38s
cloud-init 24.4 nomme le profil NetworkManager d'après la clé du network-config (eth0) et le cherche d'après l'interface (ens3) : la 2e interface n'est jamais activée, et au redémarrage le profil de repli porte le même UUID, nmcli up échoue (degraded done). Correctif dans l'image : fichier nommé par interface, contrôlé par check.sh. test.sh sert un network-config au format de two (2 NIC décrites, 1 sans entrée) et vérifie cloud-init après redémarrage. Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
e2ee4665fc
commit
344363d49c
5 changed files with 52 additions and 13 deletions
28
test.sh
28
test.sh
|
|
@ -9,6 +9,9 @@ QEMU_PID=""
|
|||
FAILED=0
|
||||
|
||||
KEEP=0
|
||||
MAC0=52:54:00:00:00:01
|
||||
MAC1=52:54:00:00:00:02
|
||||
MAC2=52:54:00:00:00:03
|
||||
|
||||
die () { KEEP=1; echo "!! ${1}" >&2; exit 1; }
|
||||
|
||||
|
|
@ -26,7 +29,8 @@ cleanup () {
|
|||
fi
|
||||
[ -n "${RUN}" ] || return 0
|
||||
rm -f "${RUN:?}/key" "${RUN:?}/key.pub" "${RUN:?}/root.qcow2" "${RUN:?}/data.qcow2" \
|
||||
"${RUN:?}/seed/meta-data" "${RUN:?}/seed/user-data" "${RUN:?}/seed/vendor-data"
|
||||
"${RUN:?}/seed/meta-data" "${RUN:?}/seed/user-data" "${RUN:?}/seed/vendor-data" \
|
||||
"${RUN:?}/seed/network-config"
|
||||
rmdir "${RUN}/seed"
|
||||
if [ "${KEEP}" -eq 1 ]; then
|
||||
echo "!! console conservée : ${RUN}/console.log" >&2
|
||||
|
|
@ -108,18 +112,19 @@ boot () {
|
|||
-drive "file=${RUN}/data.qcow2,format=qcow2,if=none,id=data" \
|
||||
-device scsi-hd,drive=data,bus=scsi0.0,serial=xvdb \
|
||||
-netdev "user,id=n0,net=169.254.169.0/24,hostfwd=tcp:127.0.0.1:${PORT}-:22,guestfwd=tcp:169.254.169.254:80-cmd:python3 -I ${ROOT}/metadata.py ${RUN}/seed" \
|
||||
-device virtio-net-pci,netdev=n0 \
|
||||
-netdev user,id=n1,net=10.0.3.0/24 -device virtio-net-pci,netdev=n1 &
|
||||
-device "virtio-net-pci,netdev=n0,mac=${MAC0}" \
|
||||
-netdev user,id=n1,net=10.0.3.0/24 -device "virtio-net-pci,netdev=n1,mac=${MAC1}" \
|
||||
-netdev user,id=n2,net=10.0.4.0/24 -device "virtio-net-pci,netdev=n2,mac=${MAC2}" &
|
||||
QEMU_PID=$!
|
||||
}
|
||||
|
||||
two_leases () {
|
||||
[ "$(vm "ip -4 -o addr show | awk '\$2 ~ /^en/ { print \$2 }' | sort -u | wc -l")" -ge 2 ]
|
||||
three_leases () {
|
||||
[ "$(vm "ip -4 -o addr show | awk '\$2 ~ /^en/ { print \$2 }' | sort -u | wc -l")" -ge 3 ]
|
||||
}
|
||||
|
||||
second_nic_by_two () {
|
||||
nic_without_config_by_two () {
|
||||
local nic
|
||||
nic=$(vm "ip -o link show | awk -F': ' '\$2 ~ /^en/ { print \$2 }' | sort | sed -n 2p")
|
||||
nic=$(vm "ip -br link show | awk '\$3 == \"${MAC2}\" { print \$1 }'")
|
||||
[ -n "${nic}" ] || return 1
|
||||
if vm 'command -v nmcli' >/dev/null; then
|
||||
[ "$(vm "nmcli -g GENERAL.CONNECTION device show ${nic}")" = two-all-en ]
|
||||
|
|
@ -150,6 +155,8 @@ printf 'instance-id: two-images-test\nlocal-hostname: two-images-test\n' > "${RU
|
|||
printf '#cloud-config\nusers:\n - name: syonad\n shell: /bin/bash\n sudo: "ALL=(ALL) NOPASSWD:ALL"\n ssh_authorized_keys:\n - %s\n' \
|
||||
"$(cat "${RUN}/key.pub")" > "${RUN}/seed/user-data"
|
||||
: > "${RUN}/seed/vendor-data"
|
||||
printf 'version: 2\nethernets:\n eth0:\n match:\n macaddress: "%s"\n dhcp4: true\n eth1:\n match:\n macaddress: "%s"\n dhcp4: true\n' \
|
||||
"${MAC0}" "${MAC1}" > "${RUN}/seed/network-config"
|
||||
qemu-img create -q -f qcow2 -b "${DIST}/${image}.qcow2" -F qcow2 "${RUN}/root.qcow2"
|
||||
qemu-img create -q -f qcow2 "${RUN}/data.qcow2" 1G
|
||||
|
||||
|
|
@ -157,8 +164,8 @@ boot
|
|||
wait_ssh
|
||||
check "cloud-init terminé sans erreur" cloud_init_done
|
||||
check "nom d'hôte servi par 169.254.169.254" test "$(vm hostname)" = two-images-test
|
||||
check "bail DHCP sur les deux interfaces" two_leases
|
||||
check "seconde interface configurée par le fichier de two" second_nic_by_two
|
||||
check "bail DHCP sur les trois interfaces" three_leases
|
||||
check "interface absente du network-config configurée par le fichier de two" nic_without_config_by_two
|
||||
check "disque additionnel en /dev/xvdb" vm 'test -b /dev/xvdb'
|
||||
check "aucune clé de construction" vm '! sudo grep -rq two-images-build /home /root /etc/ssh'
|
||||
if vm 'command -v getenforce' >/dev/null; then
|
||||
|
|
@ -170,7 +177,8 @@ fi
|
|||
BOOT=$(boot_id)
|
||||
vm_closing 'sudo systemctl reboot'
|
||||
wait_reboot "${BOOT}"
|
||||
check "bail DHCP sur les deux interfaces après redémarrage" two_leases
|
||||
check "cloud-init terminé sans erreur après redémarrage" cloud_init_done
|
||||
check "bail DHCP sur les trois interfaces après redémarrage" three_leases
|
||||
check "disque additionnel en /dev/xvdb après redémarrage" vm 'test -b /dev/xvdb'
|
||||
vm_closing 'sudo systemctl poweroff'
|
||||
wait_exit
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue