Netplan fails with traceback when desktop environment is installed without NetworkManager

Bug #2077194 reported by Chris Martin
6
This bug affects 1 person
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/50-cloud-init.yaml`, see contents in appendix below).

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://netplan.io/design)

How I reproduce the issue:

- Start with a clean Ubuntu 24.04 LTS system. I create an OpenStack instance from the cloud image (https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img).
- 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-manager-config-connectivity-ubuntu network-manager-openvpn-gnome network-manager-pptp-gnome`
- Install the desktop environment: `sudo apt-get install ubuntu-desktop-minimal`.
- 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.service: Unit NetworkManager.service not found.
Traceback (most recent call last):
  File "/usr/sbin/netplan", line 23, in <module>
    netplan.main()
  File "/usr/share/netplan/netplan_cli/cli/core.py", line 58, in main
    self.run_command()
  File "/usr/share/netplan/netplan_cli/cli/utils.py", line 298, in run_command
    self.func()
  File "/usr/share/netplan/netplan_cli/cli/commands/apply.py", line 65, in run
    self.run_command()
  File "/usr/share/netplan/netplan_cli/cli/utils.py", line 298, in run_command
    self.func()
  File "/usr/share/netplan/netplan_cli/cli/commands/apply.py", line 302, in command_apply
    utils.systemctl_network_manager('start', sync=sync)
  File "/usr/share/netplan/netplan_cli/cli/utils.py", line 105, in systemctl_network_manager
    return systemctl(action, [NM_SERVICE_NAME], sync) # pragma: nocover (covered in autopkgtest)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/share/netplan/netplan_cli/cli/utils.py", line 117, in systemctl
    subprocess.check_call(command)
  File "/usr/lib/python3.12/subprocess.py", line 413, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['systemctl', 'start', '--no-block', 'NetworkManager.service']' returned non-zero exit status 5
```

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/apt.conf.d/01-vendor-ubuntu`, add line `APT::Default-Release "noble";`
- In `/etc/apt/sources.list.d/ubuntu.sources`, add word `oracular` to the line `Suites: noble noble-updates noble-backports`
- In `/etc/apt/preferences.d`, created file `pinning` with following contents:

```
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-generator/oracular python3-netplan/oracular`

---

Appendix B: contents of our `/etc/netplan/50-cloud-init.yaml`

```
network:
    version: 2
    ethernets:
        enp1s0:
            dhcp4: true
            match:
                macaddress: fa:16:3e:69:d9:ee
            set-name: enp1s0
```

Chris Martin (6-chris-z)
description: updated
Revision history for this message
Lukas Märdian (slyon) wrote (last edit ):

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.

Changed in netplan:
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
Chris Martin (6-chris-z) wrote :

Lukas, I appreciate the helpful response. Overriding the global renderer fixed the problem for us. I should have looked in `/usr/lib/netplan`.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.