From d521b732638f88b1e6b13a12028cb61468ed4d57 Mon Sep 17 00:00:00 2001 From: vcandapp Date: Fri, 6 Dec 2024 16:32:07 +0530 Subject: [PATCH] Prevent NM from automatic (DHCP/SLAAC) configuration on ethernet devices When edpm_network_config role uses os-net-config to perform host network configuration, duplicate DHCP requests from NM are causing issue. Eg. https://issues.redhat.com/browse/OSPRH-9142 This fix prevents NM to configure DHCP by default Signed-off-by: vcandapp --- playbooks/configure_network.yml | 2 +- .../molecule/default/converge.yml | 1 + .../molecule/default/prepare.yml | 3 ++- roles/edpm_network_config/tasks/main.yml | 24 ++++++++++++++++--- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/playbooks/configure_network.yml b/playbooks/configure_network.yml index f9e2e0062..cf91efbb2 100644 --- a/playbooks/configure_network.yml +++ b/playbooks/configure_network.yml @@ -12,7 +12,7 @@ name: osp.edpm.edpm_ovs tags: - edpm_ovs - # Sets up network using OVS + # Sets up EDPM network using os-net-config - name: Import edpm_network_config ansible.builtin.import_role: name: osp.edpm.edpm_network_config diff --git a/roles/edpm_network_config/molecule/default/converge.yml b/roles/edpm_network_config/molecule/default/converge.yml index 2dcd0c467..b97840b05 100644 --- a/roles/edpm_network_config/molecule/default/converge.yml +++ b/roles/edpm_network_config/molecule/default/converge.yml @@ -33,5 +33,6 @@ next_hop: 192.168.180.1 edpm_network_config_manage_service: false edpm_network_config_hide_sensitive_logs: false + edpm_network_config_nmstate: false roles: - role: "osp.edpm.edpm_network_config" diff --git a/roles/edpm_network_config/molecule/default/prepare.yml b/roles/edpm_network_config/molecule/default/prepare.yml index 6bf7da7e0..eaa69b38c 100644 --- a/roles/edpm_network_config/molecule/default/prepare.yml +++ b/roles/edpm_network_config/molecule/default/prepare.yml @@ -22,6 +22,7 @@ test_deps_setup_edpm: true test_deps_extra_packages: - iproute + - NetworkManager - name: Prepare hosts: all gather_facts: false @@ -34,7 +35,7 @@ name: network-scripts state: present when: - - ansible_facts['distribution_major_version'] is version('8', '==') + - ansible_facts['distribution_major_version'] is version('8', '>=') - name: Create a dummy network interface ansible.builtin.command: "ip link add dummy0 type dummy" register: ip_command_output diff --git a/roles/edpm_network_config/tasks/main.yml b/roles/edpm_network_config/tasks/main.yml index d63c7be89..1d024cd8a 100644 --- a/roles/edpm_network_config/tasks/main.yml +++ b/roles/edpm_network_config/tasks/main.yml @@ -46,7 +46,25 @@ - name: Load system-roles.network tasks [nmstate] ansible.builtin.include_role: name: "{{ lookup('ansible.builtin.env', 'EDPM_SYSTEMROLES', default='fedora.linux_system_roles') + '.network' }}" -- name: Load edpm_network_config tasks [os-net-config] - ansible.builtin.include_tasks: - file: network_config.yml + +- name: Disable auto-configuration of all interfaces by NetworkManager when: edpm_network_config_tool == 'os-net-config' + become: true + block: + - name: Set 'no-auto-default' in /etc/NetworkManager/NetworkManager.conf + community.general.ini_file: + path: /etc/NetworkManager/NetworkManager.conf + state: present + mode: "0644" + no_extra_spaces: true + section: main + option: no-auto-default + value: "*" + backup: true + - name: Restart NetworkManager + ansible.builtin.systemd: + name: NetworkManager + state: restarted + - name: Load edpm_network_config tasks for os-net-config tool + ansible.builtin.include_tasks: + file: network_config.yml