Ordering of mapping keys matter
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Netplan |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
For some reason it matters the order you define the keys in the network mapping. This just seems incorrect when a mapping doesn't really define an order.
The following fails to work:
network:
bridges:
br0:
addresses:
- 192.168.122.69/24
gateway4: 192.168.122.1
interfaces:
- ens4
macaddress: 52:54:00:0d:c0:48
mtu: 1500
nameservers:
addresses:
- 192.168.122.2
search:
- maas
parameters:
stp: false
ethernets:
ens4:
match:
macaddress: 52:54:00:0d:c0:48
mtu: 1500
set-name: ens4
version: 2
Errors with "Error in network definition /etc/netplan/
If ethernets is placed before bridges then it works correctly. This just seems completely wrong when it comes to writing YAML. If it was a list I would agree the order matters but being a mapping the order should not matter.
The following works:
network:
ethernets:
ens4:
match:
macaddress: 52:54:00:0d:c0:48
mtu: 1500
set-name: ens4
bridges:
br0:
addresses:
- 192.168.122.69/24
gateway4: 192.168.122.1
interfaces:
- ens4
macaddress: 52:54:00:0d:c0:48
mtu: 1500
nameservers:
addresses:
- 192.168.122.2
search:
- maas
parameters:
stp: false
version: 2
This was noticed because MAAS creates a dictionary and then renders the YAML with yaml.dumps which places the order of the keys alphabetically.
https:/ /bugs.launchpad .net/maas/ +bug/1817931