Provide an option to avoid the yaml NM backend

Bug #2041491 reported by Alkis Georgopoulos
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
netplan.io (Ubuntu)
Confirmed
Undecided
Unassigned
network-manager (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

Hi, recently netplan added support for a yaml NM backend:

https://discourse.ubuntu.com/t/call-for-testing-networkmanager-yaml-settings/32420

The rationale is that "the descriptive YAML layer is especially useful in cloud environments":

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/556

It's great that you care about that user group!
Please also care for the rest of us that do not use cloud environments!

For example, I routinely review, clone, backup or even directly edit the /etc/NetworkManager/system-connections files in my desktops and servers, in all distributions.

Having an Ubuntu-specific way to do things will make things harder for me. I will have to learn a new Ubuntu-specific syntax, develop scripts and methods to convert my connections between distributions, I will need to discover and report bugs in the netplan <=> nm mapping etc...

I.e. Ubuntu is great for the cloud, and it's awesome that you want to provide a unified yaml-based experience for cloud-init etc.
But Ubuntu is also great outside the cloud; please allow us to continue having a unified experience between distributions (i.e. directly using nm or systemd-networkd) without enforcing an Ubuntu-specific way of doing things (netplan) to us.

For Ubuntu 24.04+, please provide an option to avoid the yaml NM backend, thank you very much!

Lukas Märdian (slyon)
tags: added: netplan-everywhere
tags: added: rls-nn-incoming
Revision history for this message
Lukas Märdian (slyon) wrote :

Thank you for your thoughtful report!

This change was not just made to be useful in cloud environments, but also is about unification of network configuration across the different variants of Ubuntu (Desktop/Server/Core/Cloud/..), to improve the UX for Ubuntu users. I understand this impacts the cross-distro compatibility of our NetworkManager packaging.

If you want to manage your NM connection profiles manually, you could place the keyfiles in /usr/lib/NetworkManager/system-connections/ and NM will pick them up as before. But those connections would no be visible to Netplan and any modifications through the NetworKManager tooling (GUI, nmtui, nmcli, ...) would write the modifications to /etc/netplan/ instead of /etc/NetworkManager/system-connections/

Revision history for this message
Alkis Georgopoulos (alkisg) wrote :

Thank you; if I understood correctly, that method would render all the NM GUI/console tools unusable; it's not a viable workaround, as I would like to be able to use these tools as well... E.g.:

- Create a new bond => GUI, nmtui, nmcli
- Did I forget any setting while creating that bond? Let's compare it with a Debian box => `meld ubuntu-box:/etc/NetworkManager/system-connections debian-box:/etc/NetworkManager/system-connections`

Lukas Märdian (slyon)
tags: removed: rls-nn-incoming
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in netplan.io (Ubuntu):
status: New → Confirmed
Changed in network-manager (Ubuntu):
status: New → Confirmed
Revision history for this message
Thomas (t.c) wrote (last edit ):

I also would like to opt-out to the Netplan Backend in NM, without recomplie the whole stuff.
As already written on that page*, I dont like to be forced to that backend.

It could be such a easy job, if the original keyfile plugin would not be patched that way it got - and if it could be compiled with a extra name like keyfile-netplan or something.

So there could also be two plugin distibution packages, we can select to install.

* https://discourse.ubuntu.com/t/call-for-testing-networkmanager-yaml-settings/32420/21

Revision history for this message
Lukas Märdian (slyon) wrote (last edit ):

Another option/idea I'd like to provide here is the migration script used by NetworkManager [1], to transfer NM keyfiles from /etc/NetworkManager/system-conncetions/ into /etc/netplan. This script is automatically run on package upgrade of NetworkManager. I understand this does not exactly fit the usecase described by alkisg, as you'd go from debian-box:/etc/NetworkManager/system-connections -> ubuntu-box:/etc/NetworkManager/system-connections -> migrate.sh -> ubuntu-box:/run/NetworkManager/system-connections

Running "./migrate.sh configure" would transfer your copied original NM keyfiles from a different box into Netplan and re-generate them in /run/NetworkManager/system-connections:

```bash
# Run "Netplan Everywhere" migration after debhelper (re-)started
# NetworkManager.service for us. On every package upgrade.
DIR="/etc/NetworkManager/system-connections"
if [ "$1" = "configure" ] && [ -d "$DIR" ]; then
    mkdir -p /run/netplan/nm-migrate
    for CON in /etc/NetworkManager/system-connections/*; do
        TYPE=$(file -bi "$CON" | cut -s -d ";" -f 1)
        [ "$TYPE" = "text/plain" ] || continue # skip non-keyfiles
        UUID=$(grep "^uuid=" "$CON" | cut -c 6-)
        if [ -n "$UUID" ]
        then
            # Wait for NetworkManager startup to complete,
            # so we can safely use nmcli. Wait in every interation to handle
            # a crashed NetworkManager in the previous migraiton step.
            if ! nm-online -qs; then
                echo "SKIP: NetworkManager is not ready ..." 1>&2
                continue
            fi
            BACKUP="/run/netplan/nm-migrate/"$(basename "$CON")
            ORIG_NAME=$(nmcli --get-values connection.id con show "$UUID") || \
                { echo "SKIP: $(basename "$CON") ($UUID) unknown to NetworkManager." 1>&2 && \
                  continue; }
            cp "$CON" "$BACKUP"
            echo "Migrating $ORIG_NAME ($UUID) to /etc/netplan" 1>&2
            # Touch the connection's ID (con-name) to trigger its migration.
            # The Netplan integration will translate the original NM keyfile from
            # /etc/NetworkManager/system-connections/* to a YAML file located in
            # /etc/netplan/90-NM-*.yaml and re-generate a corresponding keyfile in
            # /run/NetworkManager/system-connections/netplan-NM-*.nmconnection
            nmcli con mod "$UUID" con-name "$ORIG_NAME" || \
                (echo "FAILED. Restoring backup ..." 1>&2 && mv "$BACKUP" "$CON" && \
                 rm -f "/etc/netplan/90-NM-$UUID"*.yaml)
            rm -f "$BACKUP" # clear backup (if it still exists)
       fi
    done
    rm -rf /run/netplan/nm-migrate # cleanup after ourselves
    (nm-online -qs && nmcli con reload) || echo "WARNING: NetworkManager could not reload connections ..." 1>&2
fi
```

[1] https://git.launchpad.net/network-manager/tree/debian/network-manager.postinst#n62

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.