Non-Destructively Disabling Netplan on Ubuntu
Netplan has been part of Ubuntu for almost a decade now, and it’s actually pretty good at its job, which is to provide a unified, human-readable interface for configuring either systemd-networkd (on Ubuntu Server) or NetworkManager (on Ubuntu Desktop). Let’s be honest, manually configuring systemd-networkd isn’t for the faint of heart, especially for more complex scenarios like bonding.
However: I don’t need Netplan, because I can configure systemd-networkd directly with Puppet (or possibly OpenVox in the future). Netplan can play nice in this scenario, since it writes to /run/systemd/network/ instead of /etc/systemd/network/, but I don’t want it fighting with my configuration management tools over something as critical as network configuration.
Problem: Metapackages
So, why not just purge Netplan with apt purge netplan.io && apt autoremove? Well, because doing so breaks the ubuntu-minimal metapackage:
This package [ubuntu-minimal] depends on all of the packages in the Ubuntu minimal system … It is also used to help ensure proper upgrades, so it is recommended that it not be removed.
Ubuntu certainly won’t stop you from doing this, but breaking metapackages is a great way to run into weird issues down the road.
Solution: Purge Config & Reapply
Here’s my compromise: Leave Netplan installed, but purge its config files. Fortunately, this is pretty simple. According to the FAQ, Netplan config files may exist in three different directories, in order of precedence:
/run/netplan//etc/netplan//lib/netplan/
The key is to run netplan apply after removing the relevant files from those directories. This removes Netplan’s generated configuration from the network stack.
Note: This is a disruptive action, so make sure you have an alternate network configuration ready to take over after Netplan lets go of the reins!
All together, the whole process might look something like this:
$ sudo rm -f /run/netplan/*.yaml /etc/netplan/*.yaml /lib/netplan/*.yaml && sudo netplan apply
Example Puppet Code
If you’re a Puppet aficionado, here’s one way to do this from inside a module:
file { '/etc/netplan/':
ensure => directory,
owner => 'root',
group => 'root',
mode => '0755',
purge => true,
recurse => true,
force => true,
} ~>
exec { "${module_name}_regenerate_config":
command => 'netplan apply',
path => [ '/sbin', '/usr/sbin', '/bin', '/usr/bin' ],
refreshonly => true,
}