Skip to content

Commit 161071f

Browse files
committed
fix(cloud-init): decouple network config from MAC address to resolve init failure
KAG-8286
1 parent 4331cb3 commit 161071f

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

cloud-init.sh.tmpl

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,40 @@
11
#!/bin/bash -x
22

3+
if [[ $(whoami) == root ]]; then
4+
echo "Applying Network Fix: Detecting interface and ignoring MAC mismatch..."
5+
6+
ETH_DEV=$(ip -o link show up | awk -F': ' '{print $2}' | grep -vE "^(lo|docker|veth|br|virbr)" | head -n 1)
7+
8+
echo "Detected primary interface: $ETH_DEV"
9+
10+
if [[ -z "$ETH_DEV" ]]; then
11+
echo "WARNING: Could not detect interface, falling back to enp3s0"
12+
ETH_DEV="enp3s0"
13+
fi
14+
15+
cat <<EOF > /etc/netplan/99-force-dhcp.yaml
16+
network:
17+
version: 2
18+
ethernets:
19+
$ETH_DEV:
20+
dhcp4: true
21+
dhcp6: false
22+
match:
23+
name: $ETH_DEV
24+
set-name: $ETH_DEV
25+
EOF
26+
27+
rm -f /etc/netplan/50-cloud-init.yaml
28+
29+
chmod 600 /etc/netplan/99-force-dhcp.yaml
30+
netplan apply
31+
32+
ip link set $ETH_DEV up
33+
34+
echo "Waiting for DHCP on $ETH_DEV..."
35+
sleep 5
36+
fi
37+
338
if [[ $(whoami) == root ]]; then
439
# temporary hack to disable coredump to prevent OOM
540
systemctl mask systemd-coredump.socket

0 commit comments

Comments
 (0)