kayobe/roles/kayobe-network-bootstrap/tasks/main.yml
Mark Goddard 3bbf736d8d Ubuntu: support systemd-networkd
This change adds support for network configuration via systemd-networkd
on Ubuntu systems.

This is implemented via an Ansible Galaxy role,
stackhpc.systemd_networkd which was forked from
aruhier.systemd_networkd. Several improvements were made in
https://github.com/stackhpc/ansible-role-systemd-networkd/pull/1,
including:

* Add support for removing unexpected config files
* Use become where necessary
* Refactor config generation into a single task to improve performance

The systemd_networkd role does not add much abstraction on top of the
systemd-networkd configuration file format, which provides a lot of
flexibility at the expense of additional code in Kayobe. This code is
implemented as filter plugins, similarly to the existing
MichaelRigart.interfaces role.

This patch includes support for:

* Ethernet interfaces
* bridges
* bonds
* VLANs
* virtual Ethernet pairs (to connect Linux bridges and OVS bridges)
* static IP addresses
* static routes
* MTU

Some network attributes are currently not supported for
systemd-networkd:

* rules
* route options
* ethtool_opts
* zone
* allowed addresses

Story: 2004960
Task: 41881

Change-Id: I248b5bb9ce5a80a07a2a311cb3aca6daca920720
2021-04-21 08:23:44 +00:00

25 lines
1.0 KiB
YAML

---
- name: Ensure all-in-one network bridge and dummy interfaces exist
become: true
command: "{{ item }}"
with_items:
- "ip l add {{ bridge_interface }} type bridge"
- "ip l add {{ bridge_port_interface }} type dummy"
- name: Ensure all-in-one network bridge interface exists
vars:
bridge_cidr: "{{ bridge_ip }}/{{ bridge_prefix }}"
bridge_broadcast: "{{ bridge_cidr | ipaddr('broadcast') }}"
command: "{{ item }}"
become: true
with_items:
- "ip l set {{ bridge_interface }} up"
- "ip a add {{ bridge_cidr }} brd {{ bridge_broadcast }} dev {{ bridge_interface }}"
# NOTE(mgoddard): CentOS 8 removes interfaces from their bridge during
# ifdown, and removes the bridge if there are no interfaces left. When
# Kayobe bounces veth links plugged into the bridge, it causes the
# bridge which has the IP we are using for SSH to be removed. Use a
# dummy interface.
- "ip l set {{ bridge_port_interface }} up"
- "ip l set {{ bridge_port_interface }} master {{ bridge_interface }}"