So I found a minimal reproducer and prepared a unit-test case:
```
#!/bin/bash
# setup
netplan set network.renderer=NetworkManager --origin-hint=00-no-netdefs-just-globals
netplan set network.ethernets.eth99.dhcp4=true --origin-hint=90-some-netdefs
ls -l /etc/netplan/
# test
netplan set network.ethernets.eth99=NULL
# result
cat /etc/netplan/00-no-netdefs-just-globals.yaml
```
```
def test_set_no_netdefs_just_globals(self): # LP: #2027584
keepme1 = os.path.join(self.workdir.name, 'etc', 'netplan', '00-no-netdefs-just-renderer.yaml')
with open(keepme1, 'w') as f: f.write('''network: {renderer: NetworkManager}''')
deleteme = os.path.join(self.workdir.name, 'etc', 'netplan', '90-some-netdefs.yaml')
with open(deleteme, 'w') as f: f.write('''network: {ethernets: {eth99: {dhcp4: true}}}''')
self._set(['ethernets.eth99=NULL']) self.assertFalse(os.path.isfile(deleteme)) self.assertTrue(os.path.isfile(keepme1))
with open(keepme1, 'r') as f:
yml = yaml.safe_load(f) self.assertEqual('NetworkManager', yml['network']['renderer'])
```
The issue seems to happen in Jammy+ so it's not necessarily a regression.
Especially, the "unlink" part at the bottom of netplan.c:netplan_state_update_yaml_hierarchy seems to ignore any global values (such as "renderer" or "version") and operates on netdefs only.
So I found a minimal reproducer and prepared a unit-test case:
``` renderer= NetworkManager --origin- hint=00- no-netdefs- just-globals ethernets. eth99.dhcp4= true --origin- hint=90- some-netdefs ethernets. eth99=NULL 00-no-netdefs- just-globals. yaml
#!/bin/bash
# setup
netplan set network.
netplan set network.
ls -l /etc/netplan/
# test
netplan set network.
# result
cat /etc/netplan/
```
``` no_netdefs_ just_globals( self): # LP: #2027584 join(self. workdir. name, 'etc', 'netplan',
'00-no- netdefs- just-renderer. yaml')
f. write(' ''network: {renderer: NetworkManager}''') join(self. workdir. name, 'etc', 'netplan',
'90- some-netdefs. yaml')
f. write(' ''network: {ethernets: {eth99: {dhcp4: true}}}''')
def test_set_
keepme1 = os.path.
with open(keepme1, 'w') as f:
deleteme = os.path.
with open(deleteme, 'w') as f:
with open(keepme1, 'r') as f:
yml = yaml.safe_load(f)
```
The issue seems to happen in Jammy+ so it's not necessarily a regression.
I'm fairly sure it's related to the combination of (as SRUed into Jammy via 0.105-0ubuntu2~ 22.04.2) : /github. com/canonical/ netplan/ pull/254 /github. com/canonical/ netplan/ pull/299
https:/
https:/
Especially, the "unlink" part at the bottom of netplan. c:netplan_ state_update_ yaml_hierarchy seems to ignore any global values (such as "renderer" or "version") and operates on netdefs only.
=> It should probably be fixed in conjunction with https:/ /bugs.launchpad .net/netplan/ +bug/2003727