systemd_networkd network template doesn't allow multiple static routes
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenStack-Ansible |
Fix Released
|
High
|
Dmitriy Rabotyagov |
Bug Description
The systemd-network.j2 template loops static routes into individual "[Route]" sections.
https:/
Duplicate section names doesn't seem to be supported by the config_template module, so all keys are written within a single Route section.
In yoga, the lxc_container_
This was migrated in zed to use the systemd_network role, which using config_template.
https:/
---
Given:
"static_routes": [
{
"cidr": "10.91.0.0/26",
"gateway": "10.91.0.1"
},
{
"cidr": "10.89.202.64/28",
"gateway": "10.91.0.1"
}
]
Expected:
[Route]
Destination=
Gateway=10.91.0.1
Metric=21
[Route]
Destination=
Gateway=10.91.0.1
Metric=22
Actual:
[Route]
Destination = 10.89.202.64/28
Destination = 10.91.0.0/26
Gateway = 10.91.0.1
Metric = 21
Metric = 22
description: | updated |
description: | updated |
description: | updated |
Changed in openstack-ansible: | |
status: | New → Confirmed |
importance: | Undecided → High |
Thanks for reporting that.
That is indeed the case with config_template. I've looked back at systemd_networkd role and it was using config_template almost from the very beginning.
How config_template works, is that it uses Python ConfigParser for .ini files, which is generally do not contain duplicated sections, and structure is being parsed as a simple dictionary.
Though we already modify default type that is being passed to ConfigParser from a dictionary to custom type parented from OrderedDict.
What was changed there, is that sections are actually merged together, so keys from the section names that are same appear in that section all together, since value is quite trivial to transform.
But the problem is that section names act as a dictionary key, that must be unique. Maybe we can somehow trick around and represent data as sets while still have dict interface, though it could be slightly tricky.
Another way around is that we can indeed just use template for systemd_networkd role, though overrides won't be possible there which is also nasty downside.
I will have a look at what can be done shortly.