From db7c1e8a7cff8dbc03f7ce1be203bbeec73383c0 Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Mon, 26 Dec 2022 16:32:15 +0100 Subject: [PATCH] Allow to create OVS bridge for lxcbr0 This patch aims to handle creation of OVS bridge if `lxc_net_bridge_type` is set to `openvswitch`. That will finalize path when deployer prefers to have OVS as the only bridge provider and do not use LXB for any bridges. Change-Id: Idd7a6eecf718df7fd8b4ae008f7dc00e42e8c32c --- defaults/main.yml | 3 ++- tasks/lxc_net.yml | 14 +++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index f49a75b7..512b3adc 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -100,7 +100,8 @@ lxc_net_managed: true # lxc container net network lxc_net_bridge: lxcbr0 -lxc_net_bridge_port: none +# Can be 'linuxbridge' or 'openvswitch' +lxc_net_bridge_type: linuxbridge lxc_net_address: 10.0.3.1 lxc_net_netmask: 255.255.255.0 lxc_net_cidr: 24 diff --git a/tasks/lxc_net.yml b/tasks/lxc_net.yml index f7320374..1ba8578f 100644 --- a/tasks/lxc_net.yml +++ b/tasks/lxc_net.yml @@ -54,13 +54,18 @@ tags: - lxc-net +- name: Setup LXC OVS Bridge + openvswitch_bridge: + bridge: "{{ lxc_net_bridge }}" + fail_mode: standalone + state: present + when: lxc_net_bridge_type == 'openvswitch' + - name: Run the systemd-networkd role include_role: name: systemd_networkd vars: - systemd_networkd_prefix: "lxc-net" - systemd_run_networkd: true - systemd_netdevs: + _lxc_net_bridge_devices: - NetDev: Name: "{{ lxc_net_bridge }}" Kind: bridge @@ -69,6 +74,9 @@ HelloTimeSec: 2 MaxAgeSec: 12 STP: off + systemd_networkd_prefix: "lxc-net" + systemd_run_networkd: true + systemd_netdevs: "{{ (lxc_net_bridge_type == 'openvswitch') | ternary([], _lxc_net_bridge_devices) }}" systemd_networks: - interface: "{{ lxc_net_bridge }}" address: "{{ lxc_net_address }}"