From 7186f960d93f2e523a2052acd0287e176f7ac927 Mon Sep 17 00:00:00 2001 From: Bartosz Bezak Date: Tue, 12 Sep 2023 14:03:19 +0200 Subject: [PATCH] Add option for extra kernel modules in neutron role Closes-Bug: #2036741 Change-Id: Ib448d04e43dff78e344064161beadae917c41206 --- ansible/roles/neutron/defaults/main.yml | 7 ++++++ ansible/roles/neutron/tasks/config-host.yml | 5 ++--- doc/source/reference/networking/neutron.rst | 22 +++++++++++++++++++ ...ustom-kernel-modules-d105d3f84665e0a4.yaml | 6 +++++ tests/templates/globals-default.j2 | 4 ++++ tests/test-core-openstack.sh | 20 +++++++++++++++++ 6 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/add-neutron-custom-kernel-modules-d105d3f84665e0a4.yaml diff --git a/ansible/roles/neutron/defaults/main.yml b/ansible/roles/neutron/defaults/main.yml index 00cb2a368d..d0e96646bc 100644 --- a/ansible/roles/neutron/defaults/main.yml +++ b/ansible/roles/neutron/defaults/main.yml @@ -712,6 +712,13 @@ neutron_bootstrap_services: "{{ neutron_subprojects | selectattr('enabled') | ma neutron_enable_rolling_upgrade: "yes" neutron_rolling_upgrade_services: "{{ neutron_subprojects | selectattr('enabled') | map(attribute='name') | list }}" +#################### +# Neutron modules +#################### +neutron_modules_default: + - name: 'ip6_tables' +neutron_modules_extra: [] + #################### # Service Plugins #################### diff --git a/ansible/roles/neutron/tasks/config-host.yml b/ansible/roles/neutron/tasks/config-host.yml index b0b1c6fc38..9839955de6 100644 --- a/ansible/roles/neutron/tasks/config-host.yml +++ b/ansible/roles/neutron/tasks/config-host.yml @@ -1,10 +1,9 @@ --- -- name: Load and persist ip6_tables module +- name: Load and persist kernel modules include_role: name: module-load vars: - modules: - - {'name': ip6_tables} + modules: "{{ neutron_modules_default + neutron_modules_extra }}" when: >- neutron_services | select_services_enabled_and_mapped_to_host | diff --git a/doc/source/reference/networking/neutron.rst b/doc/source/reference/networking/neutron.rst index 779bb7d133..3c6b4d1198 100644 --- a/doc/source/reference/networking/neutron.rst +++ b/doc/source/reference/networking/neutron.rst @@ -214,3 +214,25 @@ authentication in external systems (e.g. in ``networking-generic-switch`` or You can set ``neutron_ssh_key`` variable in ``passwords.yml`` to control the used key. + +Custom Kernel Module Configuration for Neutron +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Neutron may require specific kernel modules for certain functionalities. +While there are predefined default modules in the Ansible role, users have +the flexibility to add custom modules as needed. + +To add custom kernel modules for Neutron, modify the configuration in +``/etc/kolla/globals.yml``: + +.. code-block:: yaml + + neutron_modules_extra: + - name: 'nf_conntrack_tftp' + params: 'hashsize=4096' + +In this example: + +- `neutron_modules_extra`: Allows users to specify additional modules and + their associated parameters. The given configuration adjusts the + `hashsize` parameter for the `nf_conntrack_tftp` module. diff --git a/releasenotes/notes/add-neutron-custom-kernel-modules-d105d3f84665e0a4.yaml b/releasenotes/notes/add-neutron-custom-kernel-modules-d105d3f84665e0a4.yaml new file mode 100644 index 0000000000..3ffba775b6 --- /dev/null +++ b/releasenotes/notes/add-neutron-custom-kernel-modules-d105d3f84665e0a4.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + Added capability to specify custom kernel modules for Neutron: + `neutron_modules_default`: Lists default modules. + `neutron_modules_extra`: For custom modules and parameters. diff --git a/tests/templates/globals-default.j2 b/tests/templates/globals-default.j2 index 3abfb4995b..17a3125f94 100644 --- a/tests/templates/globals-default.j2 +++ b/tests/templates/globals-default.j2 @@ -198,3 +198,7 @@ enable_venus: "yes" {% if groups['all'] | length == 1 %} keepalived_track_script_enabled: "no" {% endif %} + +neutron_modules_extra: + - name: 'nf_conntrack_tftp' + - name: 'nf_nat_tftp' diff --git a/tests/test-core-openstack.sh b/tests/test-core-openstack.sh index c7fe05d475..d00c1801e3 100755 --- a/tests/test-core-openstack.sh +++ b/tests/test-core-openstack.sh @@ -209,6 +209,25 @@ function unset_cirros_image_q35_machine_type { openstack image unset --property hw_machine_type cirros } +function test_neutron_modules { + # Exit the function if scenario is "ovn" or if there's an upgrade + # as inly concerns ml2/ovs + if [[ $SCENARIO == "ovn" ]] || [[ $HAS_UPGRADE == "yes" ]]; then + return + fi + + local modules + modules=( $(sed -n '/neutron_modules_extra:/,/^[^ ]/p' /etc/kolla/globals.yml | grep -oP '^ - name: \K[^ ]+' | tr -d "'") ) + for module in "${modules[@]}"; do + if ! grep -q "^${module} " /proc/modules; then + echo "Error: Module $module is not loaded." + exit 1 + else + echo "Module $module is loaded." + fi + done +} + function test_ssh { local instance_name=$1 local fip_addr=$2 @@ -354,6 +373,7 @@ function test_openstack_logged { . /etc/kolla/admin-openrc.sh . ~/openstackclient-venv/bin/activate test_smoke + test_neutron_modules test_instance_boot # Check for x86_64 architecture to run q35 tests