diff --git a/roles/edpm_network_config/molecule/default/converge.yml b/roles/edpm_network_config/molecule/default/converge.yml index 2dcd0c467..4497371a8 100644 --- a/roles/edpm_network_config/molecule/default/converge.yml +++ b/roles/edpm_network_config/molecule/default/converge.yml @@ -33,5 +33,7 @@ next_hop: 192.168.180.1 edpm_network_config_manage_service: false edpm_network_config_hide_sensitive_logs: false + edpm_bootstrap_network_service: 'NetworkManager' + edpm_network_config_tool: 'os-net-config' 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..3c86781a7 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 diff --git a/roles/edpm_network_config/molecule/nmstate/converge.yml b/roles/edpm_network_config/molecule/nmstate/converge.yml index f99e338a6..f8a208f4b 100644 --- a/roles/edpm_network_config/molecule/nmstate/converge.yml +++ b/roles/edpm_network_config/molecule/nmstate/converge.yml @@ -33,5 +33,6 @@ prefix-length: 24 dhcp: false enabled: true + edpm_bootstrap_network_service: 'NetworkManager' roles: - role: osp.edpm.edpm_network_config diff --git a/roles/edpm_network_config/tasks/main.yml b/roles/edpm_network_config/tasks/main.yml index afed98124..55808b9a5 100644 --- a/roles/edpm_network_config/tasks/main.yml +++ b/roles/edpm_network_config/tasks/main.yml @@ -37,7 +37,26 @@ - 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 - when: edpm_network_config_tool == 'os-net-config' + +- name: Disable auto-configuration of all interfaces by NetworkManager + when: ( edpm_bootstrap_network_service == 'NetworkManager' ) and + ( 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