diff --git a/roles/deploy_python3_setup_ovs/README.md b/roles/deploy_python3_setup_ovs/README.md index 1f08fe925..75680f3d6 100644 --- a/roles/deploy_python3_setup_ovs/README.md +++ b/roles/deploy_python3_setup_ovs/README.md @@ -8,7 +8,9 @@ No requirement. ## Role Variables -No variable. +| Variable | Default | Description | +|--------------------------------------|---------|------------------------------------------------------------------------------------------------------------------------| +| `deploy_python3_setup_ovs_qemu_user` | `qemu` | System user that runs QEMU guests. Used for ownership of the OVS VM socket directory. Set to `libvirt-qemu` on Debian. | ## Example Playbook diff --git a/roles/deploy_python3_setup_ovs/defaults/main.yml b/roles/deploy_python3_setup_ovs/defaults/main.yml new file mode 100644 index 000000000..bed324e5b --- /dev/null +++ b/roles/deploy_python3_setup_ovs/defaults/main.yml @@ -0,0 +1,5 @@ +# Copyright (C) 2025 RTE +# SPDX-License-Identifier: Apache-2.0 + +--- +deploy_python3_setup_ovs_qemu_user: qemu \ No newline at end of file diff --git a/roles/deploy_python3_setup_ovs/tasks/main.yml b/roles/deploy_python3_setup_ovs/tasks/main.yml index 141d907af..60643dc79 100644 --- a/roles/deploy_python3_setup_ovs/tasks/main.yml +++ b/roles/deploy_python3_setup_ovs/tasks/main.yml @@ -15,9 +15,9 @@ command: cmd: "/usr/bin/pip install {{ deploy_python3_setup_ovs_pip_options }} /tmp/src/python3-setup-ovs" changed_when: true -- name: Copy seapath-config_ovs.service - ansible.builtin.copy: - src: seapath-config_ovs.service +- name: Deploy seapath-config_ovs.service + ansible.builtin.template: + src: seapath-config_ovs.service.j2 dest: /etc/systemd/system/seapath-config_ovs.service mode: '0644' notify: Trigger daemon-reload diff --git a/roles/deploy_python3_setup_ovs/files/seapath-config_ovs.service b/roles/deploy_python3_setup_ovs/templates/seapath-config_ovs.service.j2 similarity index 60% rename from roles/deploy_python3_setup_ovs/files/seapath-config_ovs.service rename to roles/deploy_python3_setup_ovs/templates/seapath-config_ovs.service.j2 index c2ac4b98e..f5196b99f 100644 --- a/roles/deploy_python3_setup_ovs/files/seapath-config_ovs.service +++ b/roles/deploy_python3_setup_ovs/templates/seapath-config_ovs.service.j2 @@ -10,6 +10,9 @@ Before=systemd-networkd.service [Service] Type=oneshot RemainAfterExit=true +ExecStartPre=/bin/mkdir -p /var/run/openvswitch/vm-sockets +ExecStartPre=/bin/chown {{ deploy_python3_setup_ovs_qemu_user }}:root /var/run/openvswitch/vm-sockets +ExecStartPre=/bin/chmod 0750 /var/run/openvswitch/vm-sockets ExecStart=/usr/local/bin/setup_ovs [Install] diff --git a/roles/deploy_python3_setup_ovs/vars/Debian.yml b/roles/deploy_python3_setup_ovs/vars/Debian.yml index d941046da..7595c2e17 100644 --- a/roles/deploy_python3_setup_ovs/vars/Debian.yml +++ b/roles/deploy_python3_setup_ovs/vars/Debian.yml @@ -3,3 +3,4 @@ # SPDX-License-Identifier: Apache-2.0 deploy_python3_setup_ovs_pip_options: "--root-user-action=ignore --no-build-isolation --prefix=/usr/" +deploy_python3_setup_ovs_qemu_user: libvirt-qemu diff --git a/roles/network_configovs/tasks/main.yml b/roles/network_configovs/tasks/main.yml index 23aec012b..560f8a9eb 100644 --- a/roles/network_configovs/tasks/main.yml +++ b/roles/network_configovs/tasks/main.yml @@ -5,6 +5,40 @@ - name: Load distribution-specific variables include_vars: "{{ seapath_distro }}.yml" +- name: Detect DPDK usage from OVS bridge configuration + set_fact: + dpdk_enabled: >- + {{ ovs_bridges | default([]) + | map(attribute='ports', default=[]) + | flatten + | selectattr('type', 'in', ['dpdk', 'dpdkvhostuserclient']) + | list | length > 0 }} + when: seapath_distro == "Debian" + +- name: Load vfio-pci module for DPDK + community.general.modprobe: + name: vfio-pci + state: present + persistent: present + when: + - dpdk_enabled | bool + +- name: Switch to OVS with DPDK support + community.general.alternatives: + name: ovs-vswitchd + path: /usr/lib/openvswitch-switch-dpdk/ovs-vswitchd-dpdk + when: + - seapath_distro == "Debian" + - dpdk_enabled | bool + +- name: Switch to OVS without DPDK support + community.general.alternatives: + name: ovs-vswitchd + path: /usr/lib/openvswitch-switch/ovs-vswitchd + when: + - seapath_distro == "Debian" + - not dpdk_enabled | bool + - name: Create OVS configuration template: src: ovs_configuration.json.j2