summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAhmed Abdelhalim <[email protected]>2026-07-21 16:56:02 +0200
committerAhmed Abdelhalim <[email protected]>2026-07-21 16:56:02 +0200
commitb1e2a5a80e45ff281f042f91b802eaab4f01135d (patch)
tree6aa5d147893e9227e7c2c82f394d948b28e3d7e5
parent4c6f17514a9c5c1f7e072af94c08f86cce47322c (diff)
Fix molecule testing DNS resolution failures
dhcpcd is installed (and enabled by its package's default preset) in the test container to mimic Raspberry Pi OS's default boot environment. Inside podman's virtual network there's no real DHCP server for it to negotiate with, so it only ever gets a link-local address and overwrites /etc/resolv.conf with an empty file (just dhcpcd's template comments, no nameserver line). This happens within the first ~1-2 minutes of container boot, which is fast enough to break DNS resolution for later apt-get tasks in the same converge run — observed failing on "network : Ensure network_packages are installed" with repeated "Temporary failure resolving 'deb.debian.org'". The network role already intends to remove dhcpcd/avahi-daemon entirely (replacing them with NetworkManager/systemd-resolved), but that removal task runs after the package-install step that was failing — so the very service being phased out was sabotaging the install of its replacement. Masking dhcpcd.service at image-build time prevents it from ever running in the test container, closing the race without touching the network role's actual task order or logic (which reflects real hardware, where dhcpcd does get a valid lease from an actual router). Confidence in this is medium Co-Authored-By: Claude.ai
-rw-r--r--molecule/raspberrypi/Dockerfile.j26
1 files changed, 6 insertions, 0 deletions
diff --git a/molecule/raspberrypi/Dockerfile.j2 b/molecule/raspberrypi/Dockerfile.j2
index b65d05ae..5ed5bcaa 100644
--- a/molecule/raspberrypi/Dockerfile.j2
+++ b/molecule/raspberrypi/Dockerfile.j2
@@ -20,6 +20,12 @@ RUN rm -f /lib/systemd/system/multi-user.target.wants/getty.target
RUN systemctl enable avahi-daemon \
&& touch /etc/locale.gen
+# dhcpcd never gets a real lease on podman's virtual network (no DHCP
+# server to answer it) and clobbers /etc/resolv.conf with an empty file,
+# breaking DNS for later apt-get tasks. Mask it here; the network role
+# still purges the dhcpcd package itself later as part of its real logic.
+RUN systemctl mask dhcpcd.service
+
VOLUME ["/sys/fs/cgroup", "/tmp", "/run", "/opt"]
CMD ["/lib/systemd/systemd"]