diff --git a/roles/edpm_network_config/defaults/main.yml b/roles/edpm_network_config/defaults/main.yml index afdf0872f..610888bed 100644 --- a/roles/edpm_network_config/defaults/main.yml +++ b/roles/edpm_network_config/defaults/main.yml @@ -39,6 +39,6 @@ edpm_network_config_nmstate: false edpm_network_config_os_net_config_mappings: {} edpm_network_config_safe_defaults: true edpm_network_config_with_ansible: true -edpm_network_config_template: templates/single_nic_vlans/single_nic_vlans.j2 +edpm_network_config_template: "" edpm_network_config_override: {} edpm_bond_interface_ovs_options: "bond_mode=active-backup" diff --git a/roles/edpm_network_config/molecule/default/prepare.yml b/roles/edpm_network_config/molecule/default/prepare.yml index 05e92a880..e2b987829 100644 --- a/roles/edpm_network_config/molecule/default/prepare.yml +++ b/roles/edpm_network_config/molecule/default/prepare.yml @@ -17,6 +17,7 @@ - name: Prepare hosts: all + become: true roles: - role: test_deps test_deps_setup_edpm: true @@ -26,12 +27,13 @@ tasks: - name: Ensure legacy scripts installed - become: true ansible.builtin.package: name: network-scripts state: present when: - ansible_facts['distribution_major_version'] is version('8', '==') - name: Create a dummy network interface - become: true ansible.builtin.command: "ip link add dummy0 type dummy" + register: ip_command_output + changed_when: ip_command_output.rc == 0 + failed_when: ip_command_output.rc != 0 diff --git a/roles/edpm_network_config/molecule/nmstate/converge.yml b/roles/edpm_network_config/molecule/nmstate/converge.yml index dc6a0b896..31cd002de 100644 --- a/roles/edpm_network_config/molecule/nmstate/converge.yml +++ b/roles/edpm_network_config/molecule/nmstate/converge.yml @@ -19,13 +19,12 @@ hosts: all vars: edpm_network_config_tool: nmstate - network_provider: nm - network_state: + edpm_network_config_template: | interfaces: - - name: dummy0 - type: dummy - state: down - ipv4: - enabled: false + - name: dummy0 + type: dummy + state: up + ipv4: + enabled: false roles: - - role: "osp.edpm.edpm_network_config" + - 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 7849c4f1d..bad15198a 100644 --- a/roles/edpm_network_config/tasks/main.yml +++ b/roles/edpm_network_config/tasks/main.yml @@ -15,31 +15,34 @@ # under the License. - name: Configure network with network role from system roles [nmstate] + when: edpm_network_config_tool == 'nmstate' block: - name: Retrieve role name [nmstate] ansible.builtin.set_fact: - systemrolename: - "{%- if ansible_facts['distribution'] == 'RedHat' -%} + systemrolename: >- + {%- if ansible_facts['distribution'] == 'RedHat' -%} redhat.rhel {%- else -%} fedora.linux {%- endif -%} - _system_roles.network" + _system_roles.network delegate_to: localhost - name: Install OVS NetworkManager plugin [nmstate] ansible.builtin.dnf: name: NetworkManager-ovs - state: latest + state: present register: nm_ovs_status - name: Restart NetworkManager after plugin installation [nmstate] ansible.builtin.systemd: name: NetworkManager state: restarted when: nm_ovs_status.changed + - name: Render network_config variable + ansible.builtin.set_fact: + network_state: "{{ edpm_network_config_template | from_yaml }}" - name: Load system-roles.network tasks [nmstate] ansible.builtin.include_role: name: "{{ systemrolename }}" - when: edpm_network_config_tool == 'nmstate' - name: Load edpm_network_config tasks [os-net-config] ansible.builtin.include_tasks: diff --git a/roles/edpm_network_config/tasks/network_config.yml b/roles/edpm_network_config/tasks/network_config.yml index e02a4ff84..644c7fb54 100644 --- a/roles/edpm_network_config/tasks/network_config.yml +++ b/roles/edpm_network_config/tasks/network_config.yml @@ -27,7 +27,7 @@ become: true when: - ansible_facts.selinux.status == "enabled" - sefcontext: + community.general.sefcontext: target: "/var/lib/edpm-config(/.*)?" setype: container_file_t selevel: s0 @@ -42,7 +42,7 @@ become: true ansible.builtin.dnf: name: os-net-config - state: latest + state: present - name: Ensure /var/lib/edpm-config directory exists become: true