I had a broken install of python in Ubuntu 18.04. To fix it I tried a lot of variations of apt purge, remove, autoclean and autoremove.
Somehow I ended up without netplan, and without network.
Fix Step 1: Enable Network
Without netplan you need to use lower-level commands to get back online, to be able to use apt and reinstall netplan. And some kind of non network-based access to the server of course.
First, find your network interface name:
:>networkctl
Next, enable the interface and set an IP:
:>sudo ifconfig eth0 up
:>sudo ip address add 192.168.1.88/25 dev eth0
:>sudo ip route add default via 192.168.1.1 dev eth0
Next, assign a DNS:
:>sudo systemd-resolve --interface=eth0 --set-dns=8.8.8.8
Congratulations! You are back on the network!
Fix Step 2: Restore netplan
Now that you have internet, you can use apt to reinstall netplan. Big gotcha: you want netplan.io, not plain netplan.
:>sudo apt update
:>sudo apt install netplan.io
Your old settings should still be in /etc/netplan/01-netcfg.yaml.
Finally:
:>sudo netplan apply
Verify the network still works.
I can't tell you exactly how to get systemd.networkd up and running properly (if any more steps are needed) since at this point I upgraded Ubuntu to 20.04.