Netplan fails with traceback when desktop environment is installed without NetworkManager
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Netplan |
Triaged
|
Medium
|
Unassigned |
Bug Description
On Ubuntu 24.04 LTS, it appears that Netplan cannot bring up a system's network interfaces on boot if a graphical desktop environment is installed, but NetworkManager is not installed.
For background: The overall goal is to offer cloud instances with a pre-installed desktop environment, but without NetworkManager's complexity (and opportunity for the user to break their own connectivity by clicking buttons in GNOME Settings). The users are researchers running a mix of graphical and command-line software. We use cloud-init to configure networking on our cloud instances (which essentially creates `/etc/netplan/
Our goal of using Netplan without NetworkManager seems to align with Netplan's design: "Retains the flexibility to [...] adjust to `apt purge network-manager`". (https:/
How I reproduce the issue:
- Start with a clean Ubuntu 24.04 LTS system. I create an OpenStack instance from the cloud image (https:/
- Optionally, set a password for local `ubuntu` user for later troubleshooting on the console (after losing network connectivity).
- Upgrade to Netplan 1.0.1-1ubuntu2 or later (see steps in appendix A below) to avoid getting stuck by LP: #1999178 when you install the desktop environment.
- To prevent APT from installing NetworkManager with the desktop environment: `sudo apt-mark hold network-manager network-
- Install the desktop environment: `sudo apt-get install ubuntu-
- Optionally, to ease troubleshooting, prevent the graphical session from starting on boot: `sudo systemctl set-default multi-user.target`.
- Reboot.
On reboot, the instance starts up but does not get network connectivity. If I log in to the instance console and run `sudo netplan apply`, I get this Python traceback:
```
Failed to start NetworkManager.
Traceback (most recent call last):
File "/usr/sbin/
netplan.main()
File "/usr/share/
self.
File "/usr/share/
self.func()
File "/usr/share/
self.
File "/usr/share/
self.func()
File "/usr/share/
utils.
File "/usr/share/
return systemctl(action, [NM_SERVICE_NAME], sync) # pragma: nocover (covered in autopkgtest)
File "/usr/share/
subprocess.
File "/usr/lib/
raise CalledProcessEr
subprocess.
```
So Netplan is trying and failing to start the NetworkManager systemd service, even though NetworkManager was _never installed_ on this system. I get a similar result if I allow NetworkManager to install with the desktop environment (skip the `apt-mark hold` step above), but mask its systemd services.
---
Appendix A: How I upgraded Netplan on 24.04 LTS
- In `/etc/apt/
- In `/etc/apt/
- In `/etc/apt/
```
Package: *
Pin: release a=oracular
Pin-Priority: 100
```
- `apt update`
- To get the newest version of Netplan, 1.1-1: `sudo apt install netplan.io/oracular netplan-
---
Appendix B: contents of our `/etc/netplan/
```
network:
version: 2
ethernets:
enp1s0:
dhcp4: true
match:
```
description: | updated |
When installing ubuntu- desktop- minimal it will pull in the "ubuntu-settings" package, installing a Netplan snippet in /usr/lib/ netplan/ 00-network- manager- all.yaml defining the global "renderer: NetworkManager" setting, which will break network configuration when NM is not installed.
To avoid this, you could need to override the global renderer setting in /etc/netplan/ 01-global- renderer. yaml, e.g:
```
network:
version: 2
renderer: networkd
```
Still, Netplan should not crash in such scenarios and we need to fix that.