debops icon indicating copy to clipboard operation
debops copied to clipboard

[networkd] Improve networkd__configuration and networkd__units

Open Alphix opened this issue 1 year ago • 0 comments

The default configuration of systemd-networkd has already changed from Bullseye to Bookworm. It used to look like this in Bullseye:

[Network] #SpeedMeter=no #SpeedMeterIntervalSec=10sec #ManageForeignRoutes=yes

[DHCP] #DUIDType=vendor #DUIDRawData=

And now it looks like this in Bookworm:

[Network] #SpeedMeter=no #SpeedMeterIntervalSec=10sec #ManageForeignRoutingPolicyRules=yes #ManageForeignRoutes=yes #RouteTable=

[DHCPv4] #DUIDType=vendor #DUIDRawData=

[DHCPv6] #DUIDType=vendor #DUIDRawData=

In order to simplify the configuration, and the templates, this patch removes the networkd__dhcp_* variables and lets the networkd__*_configuration variables define the whole content of /etc/systemd/networkd.conf.d/ansible.conf. This should be more future-proof and avoids a proliferation of configuration variables (one set of variables per section).

Furthermore, networkd__units has been changed to also support the typical universal configuration style (in addition to raw support, which has been kept).

Also, note that the behaviour of "x | bool" is not exactly intuitive: https://medium.com/opsops/wft-bool-filter-in-ansible-e7e2fd7a148f

With that in mind, I took the liberty of simplifying the shared macro logic a bit by removing the (IMHO confusing) usage of the bool filter.

The role has also been changed to use numbered unit files, which is what the man pages recommend, and is already used in some (but not all) of the examples provided in the role documentation.

Per-unit file permissions support is added (useful for e.g. WireGuard netdevs which will contain private keys).

Finally, the use by other roles is now supported via the usual dependent variable.

Alphix avatar Oct 15 '23 12:10 Alphix