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
|
|
@ -40,6 +40,12 @@ no_fixed_ntp () {
|
|||
! grep -qE '^[[:space:]]*(pool|server|peer)[[:space:]]' /mnt/etc/chrony.conf
|
||||
}
|
||||
|
||||
nm_files_by_device () {
|
||||
local dir
|
||||
dir=$(chroot /mnt python3 -c 'import cloudinit, os; print(os.path.dirname(cloudinit.__file__))') || return 1
|
||||
has_line "/mnt${dir}/net/network_manager.py" ' name = nm_conn_filename(iface["name"], target)'
|
||||
}
|
||||
|
||||
check "/var/lib/cloud vide" empty_or_absent /mnt/var/lib/cloud
|
||||
check "aucune clé d'hôte SSH" no_match /mnt/etc/ssh -maxdepth 1 -name 'ssh_host_*'
|
||||
check "aucun authorized_keys sous /root" no_match /mnt/root -name authorized_keys
|
||||
|
|
@ -60,6 +66,7 @@ case "${FAMILY}" in
|
|||
check "utilisateur par défaut syonad" has_line /mnt/etc/cloud/cloud.cfg.d/20_user.cfg " name: syonad"
|
||||
check "chrony sans serveur NTP fixe" no_fixed_ntp
|
||||
check "chrony sur les serveurs NTP du DHCP" has_line /mnt/etc/chrony.conf "sourcedir /run/chrony-dhcp"
|
||||
check "profils NetworkManager de cloud-init nommés par interface" nm_files_by_device
|
||||
;;
|
||||
esac
|
||||
|
||||
|
|
|
|||
|
|
@ -53,6 +53,28 @@ for unit in rpcbind.service rpcbind.socket; do
|
|||
fi
|
||||
done
|
||||
|
||||
CLOUDINIT=$(chroot /mnt python3 -c 'import cloudinit, os; print(os.path.dirname(cloudinit.__file__))')
|
||||
[ -n "${CLOUDINIT}" ] || die "module cloudinit introuvable dans la cible"
|
||||
patch -d "/mnt${CLOUDINIT}" -p1 --forward --fuzz=0 --no-backup-if-mismatch <<'EOF'
|
||||
--- a/net/network_manager.py
|
||||
+++ b/net/network_manager.py
|
||||
@@ -594,10 +594,11 @@
|
||||
conn.render_interface(iface, network_state, self)
|
||||
|
||||
# And finally write the files
|
||||
- for con_id, conn in self.connections.items():
|
||||
+ for iface in network_state.iter_interfaces():
|
||||
+ conn = self.connections[iface.get("config_id") or iface["name"]]
|
||||
if not conn.valid():
|
||||
continue
|
||||
- name = nm_conn_filename(con_id, target)
|
||||
+ name = nm_conn_filename(iface["name"], target)
|
||||
util.write_file(name, conn.dump(), 0o600)
|
||||
|
||||
# Select EUI64 to be used by default by NM for creating the address
|
||||
EOF
|
||||
chroot /mnt python3 -m py_compile "${CLOUDINIT}/net/network_manager.py"
|
||||
|
||||
augtool -r /mnt -s set /files/etc/selinux/config/SELINUX disabled
|
||||
augtool -r /mnt -s rm /files/etc/chrony.conf/pool
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ wait_cloud_init () {
|
|||
|
||||
install_tools () {
|
||||
case "${FAMILY}" in
|
||||
rocky) dnf -y -q install qemu-img augeas xfsprogs ;;
|
||||
rocky) dnf -y -q install qemu-img augeas xfsprogs patch ;;
|
||||
debian) DEBIAN_FRONTEND=noninteractive apt-get -qq update \
|
||||
&& DEBIAN_FRONTEND=noninteractive apt-get -qq install -y --no-install-recommends qemu-utils e2fsprogs ;;
|
||||
esac
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue