Commit Graph

19 Commits

Author SHA1 Message Date
Dmitriy Rabotyagov b9c7d79089 Use OriginalName instead of Name in systemd.link
Name option is not a valid one for systemd.link [1] while it is for systemd.network [2]
though having same meaning.

This basically resulted in link files being just ignored by udevadm
and were not loaded properly after reboot

[1] https://www.freedesktop.org/software/systemd/man/latest/systemd.link.html#OriginalName=
[2] https://www.freedesktop.org/software/systemd/man/latest/systemd.network.html#Name=

Closes-Bug: #1896589
Change-Id: If82946b7f5ad3c618606110576c586632f9bbd08
2024-02-02 11:19:00 +00:00
Dmitriy Rabotyagov 70442c5efb Fix defenition of multiple static routes for network
Current logic was relying on iteration inside the template. However,
since config_template module was used to deliver network configuration
it was merging sections having same name together.

While this behaviour is correct one for config_template as all sections
must be unique from ConfigParser perspective and in order to apply
overrides properly, it was not suiting the way how routes should be
defined in networkd configuration.

To workaround the issue we place routes separately under <network>.d
directory, which should be supported by systemd [1]

[1] https://www.freedesktop.org/software/systemd/man/latest/systemd.network.html

Closes-Bug: #2045819
Change-Id: I01aa44dcdc85e32d18dd52bcd4878a9017fb6ead
2023-12-09 05:24:57 +00:00
Andrew Bonney 4a7012e366 Handle omitted variables which appear as empty strings
Changes to external roles cause some variables to be passed in
as empty strings which result in invalid config and InvalidArgument
errors.

This could be addressed here or in the calling role.

Change-Id: Iee71e9839d4c8d318c2c36152d966dd5a1b88111
2023-01-11 08:08:37 +00:00
Andrew Bonney 5acf51aec3 Fix static routes to use Destination rather than Source key
The current template results in a default route being added to the
routing table rather than a route specific to the destination
requested.

Change-Id: I0ef53631989ea2dc12d2540edeed95d0a466353b
2023-01-10 14:56:47 +00:00
Dmitriy Rabotyagov 9b9f791377 Allow to provide multiple VLANs
In order to create multiple vlans from the same interface, VLAN
key must be repeated multiple times. At the moment our role limits
that since vlan can not be a list. We adding an option for vlan being a list
at the same time keeping backwards compatability.

Change-Id: I94bf2157e1e95c3fd5af318eac8238cd6c3b6fdc
2022-12-23 17:27:46 +01:00
Marc Gariepy d62daa24f9 Change location of ipaddr filter
ipaddr filter has been moved from netcommon to utils collection [1]

Based on that we must add that collection to requirements.

[1] db4920ebf6

Depends-On: https://review.opendev.org/c/openstack/openstack-ansible/+/831525
Change-Id: Iac92e247d209d848c82f625c190c200cdc05a67a
2022-03-02 14:59:43 -05:00
Jonathan Rosser 6b1c9e95b6 Fix linter errors and update tests
This patch fixes linter errors, updates tests, and adds the MTUBytes
interface configuration option to the systemd .network file to support
live MTU changes upon restart of systemd-networkd. Without it, MTU
changes will only be effective upon boot (might only affect Focal).

Change-Id: I05da4036b0ddc3fb88ba958f413a32fa6819de61
2020-10-28 12:34:10 -05:00
Michael Vollman 242b3c3fb4 Add ipforward option to configure IPForward
Add ipforward bool optional setting to systemd_networks to enable
or disable forwarding for a given interface.  IPForward is disabled
by default.

Change-Id: Iaea33b1bdde1964f38612ab8c278fed4985d390b
2019-02-11 09:55:26 -05:00
Kevin Carter 2921156fd1 Move link options to a link file
The link options being set within the network files, which functional,
does not expose all of the link capabilities we have within a specific
link file. This change implements link files per network interface
giving the user the ability to customize links as they need.

Change-Id: Ie999c541a6a566141e81c6d9f95b8a30bbbefa8c
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
2018-12-27 21:31:16 -06:00
Kevin Carter b0395c727e Update cleanup process and set a file prefix
The interface cleanup was generating a script that could be used to run
a cleanup whenever required. While this worked it would rapidly become
out of date, especially when multiple roles are calling this role. This
change adds a prefix which deployer can use to ensure the network
interface files are marked which will ensure we're limiting the
possibility of collisions.

The cleanup process will now use this prefix to search for and remove
any network interface file that matches the given prefix.

Change-Id: Ife5c179d27925cd2e71d3d086a731e6c13b12965
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
2018-05-19 05:40:48 +00:00
Kevin Carter 12ae3acd6e
Add resolved to the networkd setup
If the new variable systemd_resolved is defined, resolved will be setup
within the environment. This will configure the global configuration
file and restart the service.

A test has been added to ensure this code path is exercised on every
commit. It should be noted that suse does not have a resolved package so
this functionality is disabled when a suse system is encountered. This
should be revised as soon as suse has resolved available.

Change-Id: I85278719bc5b7158244fd44c65d4366935555780
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
2018-05-10 14:13:27 -05:00
Kevin Carter d8bcdc0341
Update initramfs when links change
In order to make the default link take effect initramfs needs to be
updated. This change also updates the default link to use the
recommended defaults from the systemd-networkd documentation.

Default link config:
- https://www.freedesktop.org/software/systemd/man/systemd.link.html#Examples

See this thread for bug info:
- https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=793374

Change-Id: I5430da4acad1e36b7593ad6791afbebf9e730bba
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
2018-04-16 07:51:01 -05:00
Zuul 0cd72804e9 Merge "Allow networkd filename override" 2018-03-21 03:08:45 +00:00
Logan V b9b135ab9a Allow networkd filename override
- Allow configuring the default filename format
- Allow configuring a filename override on a per netdev/network
  basis.

Change-Id: I801fe5604d543ae36daf5bd1764ef1035644ea44
2018-03-19 14:54:35 -05:00
Logan V 80c397cfb6 Use the correct var to calculate address prefix
The _addr loop was inserted but not referenced when calculating the
address host/prefix pair.

Change-Id: I970cc6c12a744fb8a28c2b0ef28e4d08b0c8e90a
2018-03-19 14:53:46 -05:00
Logan V dfc5f5578b Correctly support list of string prefixes
systemd_networks:
  - interface: dummy3
    address:
      - 10.0.2.100/24
      - 10.0.3.100/24

Change-Id: If2f08ff70b637090f0ed1091bd40ce090468a51a
2018-03-19 14:52:53 -05:00
Logan V cb229ade5c Accept multiple addresses on an interface
These are all valid configurations:

systemd_networks:
  - interface: dummy1
    address: 10.0.0.100
    netmask: 255.255.255.0
    gateway: 10.0.0.1
  - interface: dummy2
    address: 10.0.1.100/24
  - interface: dummy3
    address:
      - 10.0.2.100/24
      - address: 10.0.3.100
        netmask: 255.255.255.0
    gateway: 10.0.2.1
  - interface: eth12
    address: dhcp
2018-03-17 21:28:01 -05:00
Logan V 2a1d39a4b5 Remove the [Address] block
The Address= attribute in [Network] serves the same purpose.

See http://paste.openstack.org/show/703421/ as an example.
2018-03-17 20:57:29 -05:00
Kevin Carter dd82b31ee2
first commit
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
2018-03-13 23:09:48 -05:00