From b1e2a5a80e45ff281f042f91b802eaab4f01135d Mon Sep 17 00:00:00 2001 From: Ahmed Abdelhalim Date: Tue, 21 Jul 2026 16:56:02 +0200 Subject: Fix molecule testing DNS resolution failures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- molecule/raspberrypi/Dockerfile.j2 | 6 ++++++ 1 file changed, 6 insertions(+) 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"] -- cgit v1.2.3