desktops: flip netplan renderer to NetworkManager on live install#880
desktops: flip netplan renderer to NetworkManager on live install#880igorpecovnik merged 1 commit intomainfrom
Conversation
When a desktop is installed on top of a minimal Armbian image, the
image's networking baseline is netplan.io driving systemd-networkd
(armbian/build's extensions/network/net-systemd-networkd.sh lays
/etc/netplan/10-dhcp-all-interfaces.yaml with 'renderer: networkd').
The desktop's NM-applet / GNOME Quick Settings / Plasma plasma-nm
talk to NetworkManager, and with NM not actually driving the link
the Wi-Fi/Wired tile stays in 'disconnected' state even though the
machine is online. Worse, if the user clicks 'Connect' in the tile,
NM and networkd race for the interface.
Image-built desktop images use armbian/build's
extensions/network/net-network-manager.sh to do the flip at image
assembly time. This change runs the equivalent transition at runtime
for the install-on-minimal path so the two converge on the same
end state.
The transition:
- Remove /etc/netplan/10-dhcp-all-interfaces.yaml (the networkd
renderer drop-in the minimal image shipped).
- Install /etc/netplan/00-default-use-network-manager.yaml with
renderer: NetworkManager.
- Install the three NetworkManager conf.d drop-ins that
armbian/build's net-network-manager.sh ships: readme stub,
wifi MAC randomisation, wifi powersave disable.
- Disable NetworkManager-wait-online.service (90s boot hang
waiting for carrier on every managed interface otherwise).
- Keep systemd-resolved enabled (NM uses it as DNS cache when
/etc/resolv.conf points at the stub).
- netplan generate + netplan apply to switch the live system,
unless mode=build (deferred to first-boot) or inside a
container/CI (no real network to flip).
common.yaml's minimal tier now declares network-manager and
netplan.io directly so every DE picks them up instead of each
per-DE yaml declaring them piecemeal — current coverage was
inconsistent (gnome/mate/cinnamon/kde-plasma/i3/xmonad had them,
xfce/enlightenment/budgie/deepin/kde-neon didn't). Per-DE applet
packages (network-manager-gnome for GTK DEs, plasma-nm for KDE)
stay in the per-DE yamls since they're only pulled on the DEs
that need them.
Network assets live under tools/modules/desktops/networking/ so
the layout mirrors branding/, greeters/, skel/ — a dedicated
subdirectory per install-time concern. The function is wired into
the install pipeline after module_desktop_branding, before the
per-user group/DM work, so it runs once per install in both
build-time and runtime paths.
WalkthroughThis change introduces desktop networking configuration support by adding a new helper function that switches the system's network renderer from Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
tools/modules/desktops/networking/netplan/00-default-use-network-manager.yaml (1)
12-18: Minor: comment attributes DHCP-on-carrier to this YAML, but it's NM that provides it.The YAML declares only the renderer; it has no
ethernets/wifis/dhcp4blocks, so the "come up with DHCP once carrier is detected" behavior is actually NetworkManager's default policy (its auto-generated "Wired connection 1"-style profiles), not something netplan emits from this file. Consider tweaking the wording to make clear this is NM's default once control has been passed over. Non-blocking.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tools/modules/desktops/networking/netplan/00-default-use-network-manager.yaml` around lines 12 - 18, The comment incorrectly attributes DHCP-on-carrier behavior to this netplan YAML; update the comment to state that this file only hands control to NetworkManager (network with renderer: NetworkManager) and that NetworkManager provides the default auto-generated DHCP-on-carrier profiles (e.g., "Wired connection 1") rather than netplan emitting dhcp4/ethernets/wifis settings; keep the existing YAML (network / version: 2 / renderer: NetworkManager) but rephrase the top comment to reflect that nuance.tools/modules/desktops/module_desktops.sh (1)
190-204: Enable/start NetworkManager.service beforenetplan apply, not after.Current order:
netplan generate && netplan apply(lines 195‑196)srv_enable+srv_start NetworkManager.service(lines 203‑204)
netplan applywithrenderer: NetworkManagerwrites keyfiles to/run/NetworkManager/system-connections/and then expects NM to pick them up. If NM is disabled/masked at this point (e.g., installed into a partially-booted system, or a distro where the postinst'sdh_installsystemdhook didn't enable it because policy-rc.d denied it), the apply effectively no-ops the hand-off and the link is down until the next boot — the exact "orphaned network" the binary-presence guard at line 138 is trying to prevent.Enabling + starting NM first is cheap, idempotent, and removes the ordering dependency on
netplan apply's ability to start its backend:♻️ Proposed reordering
+ # Make sure NM is enabled + running before netplan hands off + # to it. On a freshly-installed NM the postinst usually enables + # the unit, but we can't rely on that in chroot-style installs + # where policy-rc.d blocked postinst activation. + srv_enable NetworkManager.service 2>/dev/null || true + srv_start NetworkManager.service 2>/dev/null || true + # Live install. Regenerate netplan output and apply it. netplan # apply stops systemd-networkd.service on interfaces it hands # over to NetworkManager, so the user's current SSH session over # those interfaces can stall briefly — that's expected. if command -v netplan > /dev/null 2>&1; then netplan generate 2>&1 || echo "Warning: netplan generate failed" >&2 netplan apply 2>&1 || echo "Warning: netplan apply failed" >&2 fi - - # Make sure NM is enabled + started. On a minimal image the - # service was installed a moment ago and masked/not enabled by - # default on some distros; enabling + starting here is - # idempotent. - srv_enable NetworkManager.service 2>/dev/null || true - srv_start NetworkManager.service 2>/dev/null || true🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tools/modules/desktops/module_desktops.sh` around lines 190 - 204, The netplan apply step can no-op if NetworkManager is disabled/masked; move the NetworkManager startup before running netplan so keyfiles are picked up immediately: call srv_enable and srv_start for NetworkManager.service (the existing srv_enable NetworkManager.service 2>/dev/null || true and srv_start NetworkManager.service 2>/dev/null || true invocations) before invoking netplan generate and netplan apply, preserving the same redirections and idempotent behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@tools/modules/desktops/module_desktops.sh`:
- Around line 190-204: The netplan apply step can no-op if NetworkManager is
disabled/masked; move the NetworkManager startup before running netplan so
keyfiles are picked up immediately: call srv_enable and srv_start for
NetworkManager.service (the existing srv_enable NetworkManager.service
2>/dev/null || true and srv_start NetworkManager.service 2>/dev/null || true
invocations) before invoking netplan generate and netplan apply, preserving the
same redirections and idempotent behavior.
In
`@tools/modules/desktops/networking/netplan/00-default-use-network-manager.yaml`:
- Around line 12-18: The comment incorrectly attributes DHCP-on-carrier behavior
to this netplan YAML; update the comment to state that this file only hands
control to NetworkManager (network with renderer: NetworkManager) and that
NetworkManager provides the default auto-generated DHCP-on-carrier profiles
(e.g., "Wired connection 1") rather than netplan emitting dhcp4/ethernets/wifis
settings; keep the existing YAML (network / version: 2 / renderer:
NetworkManager) but rephrase the top comment to reflect that nuance.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 77718780-bce4-41e0-a462-16800e743445
📒 Files selected for processing (6)
tools/modules/desktops/module_desktops.shtools/modules/desktops/networking/NetworkManager/00-armbian-readme.conftools/modules/desktops/networking/NetworkManager/zz-10-override-wifi-random-mac-disable.conftools/modules/desktops/networking/NetworkManager/zz-20-override-wifi-powersave-disable.conftools/modules/desktops/networking/netplan/00-default-use-network-manager.yamltools/modules/desktops/yaml/common.yaml
Summary
When a desktop is installed on top of a minimal Armbian image, the image's networking baseline is
netplan.iodrivingsystemd-networkd. The desktop's NM-applet / GNOME Quick Settings / Plasma plasma-nm all talk to NetworkManager, and with NM not actually driving the link the Wi-Fi/Wired tile stays in "disconnected" state even though the machine is online. Worse, if the user clicks Connect in the tile, NM andnetworkdrace for the interface.armbian/build's extensions/network/net-network-manager.sh already does this flip at image-assembly time for image-built desktop variants. This PR runs the equivalent transition at runtime for the install-on-minimal path so the two paths converge on the same end state.
What happens during install
After
module_desktop_brandingcopies branding assets, a new helper_module_desktops_configure_networkingruns:/etc/netplan/10-dhcp-all-interfaces.yaml(the networkd drop-in that minimal images ship)./etc/netplan/00-default-use-network-manager.yaml(renderer: NetworkManager)./etc/NetworkManager/conf.d/drop-ins that match build's extension exactly: readme stub, wifi MAC randomisation, wifi powersave disable.NetworkManager-wait-online.service(otherwise boots hang 90s waiting for carrier on every managed interface).systemd-resolvedenabled (NM uses it as DNS cache when/etc/resolv.confpoints at the stub).netplan generate && netplan apply— unlessmode=build(deferred to first-boot) or we're in a container (no real network to flip).Idempotent: safe to re-run on a system already on NetworkManager.
YAML change
common.yaml's minimal tier now pulls innetwork-manager+netplan.iodirectly. Previous coverage was inconsistent — gnome/mate/cinnamon/kde-plasma/i3-wm/xmonad had the daemon in their per-DE yamls, xfce/enlightenment/budgie/deepin/kde-neon didn't, so the first group would have had NM installed while the second group's transition would have failed at thecommand -v NetworkManagergate. Moving it to common closes that hole.Per-DE applets (
network-manager-gnomefor GTK DEs, KDE'splasma-nmviakde-plasma-desktopmetapackage) stay in the per-DE yamls — only the DEs that need them pull them.Files
tools/modules/desktops/networking/netplan/00-default-use-network-manager.yaml— mirrors build'sconfig-nm/netplan/00-default-use-network-manager.yamltools/modules/desktops/networking/NetworkManager/00-armbian-readme.conftools/modules/desktops/networking/NetworkManager/zz-10-override-wifi-random-mac-disable.conftools/modules/desktops/networking/NetworkManager/zz-20-override-wifi-powersave-disable.conftools/modules/desktops/module_desktops.sh— new helper + install-path calltools/modules/desktops/yaml/common.yaml— minimal tier gets network-manager + netplan.ioTest plan
network-manager+netplan.ioinDESKTOP_PACKAGESat the minimal tier (verified viaparse_desktop_yaml.py).network-managerin its minimal tier alongside common's; parser emits it once.bash -n module_desktops.shpasses./etc/netplan/ends up with only00-default-use-network-manager.yaml,10-dhcp-all-interfaces.yamlis gone.systemctl is-enabled NetworkManager-wait-online.servicereportsmaskedordisabled.mode=buildpath lays the netplan + conf.d files but doesn't try tonetplan apply.netplan applycleanly.