Ansible role to manage systemd networkd
Go to file
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
defaults Ensure filename is always defined for network/netdev 2023-12-08 17:51:16 +00:00
doc Switch sphinx language to en 2022-05-30 16:01:11 +02:00
examples Add integrated linters test 2022-01-25 11:29:12 +00:00
files/gpg Add centos-9 support 2022-01-11 14:14:55 +00:00
handlers Fix linters and metadata 2023-07-12 12:33:19 +02:00
html-docs first commit 2018-03-13 23:09:48 -05:00
meta Fix linters and metadata 2023-07-12 12:33:19 +02:00
releasenotes Fix defenition of multiple static routes for network 2023-12-09 05:24:57 +00:00
tasks Fix defenition of multiple static routes for network 2023-12-09 05:24:57 +00:00
templates Fix defenition of multiple static routes for network 2023-12-09 05:24:57 +00:00
tests Use ansible_facts[] instead of fact variables 2021-02-24 14:26:31 +00:00
vars Ensure filename is always defined for network/netdev 2023-12-08 17:51:16 +00:00
zuul.d Add integrated linters test 2022-01-25 11:29:12 +00:00
.gitignore Updated from OpenStack Ansible Tests 2019-08-20 03:07:47 +00:00
.gitreview OpenDev Migration Patch 2019-04-19 19:29:42 +00:00
CONTRIBUTING.rst [ussuri][goal] Update contributor documentation 2020-05-13 00:08:50 +03:00
LICENSE first commit 2018-03-13 23:09:48 -05:00
README.md Update documentation on role requirements 2022-05-13 10:42:11 +02:00
Vagrantfile Updated from OpenStack Ansible Tests 2021-12-17 16:50:36 +00:00
bindep.txt Updated from OpenStack Ansible Tests 2021-03-12 22:23:47 +00:00
manual-test.rc Update documentation on role requirements 2022-05-13 10:42:11 +02:00
requirements.yml Update documentation on role requirements 2022-05-13 10:42:11 +02:00
run_tests.sh Updated from OpenStack Ansible Tests 2022-04-04 09:22:59 +00:00
tox.ini Update tox.ini to work with 4.0 2022-12-27 17:53:06 +01:00

README.md

Ansible systemd_networkd

This Ansible role configures systemd-networkd link, network, and netdev files.

This role requires the ansible-config_template collection to be available on your local system.

To get collection you can use use the ansible-galaxy command on the requirements.yml file.. You need to install collection before running this role.

# ansible-galaxy install -r requirements.yml

Release notes for the project can be found at: https://docs.openstack.org/releasenotes/ansible-role-systemd_networkd


Example playbook

See the "defaults.yml" file for a full list of all available options.

- name: Create a systemd-networkd interfaces
  hosts: localhost
  become: true
  roles:
    - role: "systemd_networkd"
      systemd_netdevs:
        - NetDev:
            Name: dummy0
            Kind: dummy
        - NetDev:
            Name: dummy1
            Kind: dummy
        - NetDev:
            Name: bond0
            Kind: bond
          Bond:
            Mode: 802.3ad
            TransmitHashPolicy: layer3+4
            MIIMonitorSec: 1s
            LACPTransmitRate: fast
        - NetDev:
            Name: br-dummy
            Kind: bridge
      systemd_networks:
        - interface: "dummy0"
          bond: "bond0"
          mtu: 9000
        - interface: "dummy1"
          bond: "bond0"
          mtu: 9000
        - interface: "bond0"
          bridge: "br-dummy"
          mtu: 9000
        - interface: "br-dummy"
          address: "10.0.0.100"
          netmask: "255.255.255.0"
          gateway: "10.0.0.1"
          mtu: 9000
          usedns: true
          static_routes:
            - gateway: "10.1.0.1"
              cidr: "10.1.0.0/24"
          config_overrides:
            Network:
              ConfigureWithoutCarrier: true