diff --git a/roles/edpm_network_config/defaults/main.yml b/roles/edpm_network_config/defaults/main.yml index afdf0872f..ae68a07d0 100644 --- a/roles/edpm_network_config/defaults/main.yml +++ b/roles/edpm_network_config/defaults/main.yml @@ -40,5 +40,6 @@ 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_nmstate_template: templates/system_role_nmstate/single_nic_vlans.j2 edpm_network_config_override: {} edpm_bond_interface_ovs_options: "bond_mode=active-backup" diff --git a/roles/edpm_network_config/molecule/nmstate/converge.yml b/roles/edpm_network_config/molecule/nmstate/converge.yml index dc6a0b896..3efbc8ee7 100644 --- a/roles/edpm_network_config/molecule/nmstate/converge.yml +++ b/roles/edpm_network_config/molecule/nmstate/converge.yml @@ -20,12 +20,6 @@ vars: edpm_network_config_tool: nmstate network_provider: nm - network_state: - interfaces: - - name: dummy0 - type: dummy - state: down - ipv4: - enabled: false + edpm_network_config_nmstate_template: ./dummy_config.j2 roles: - role: "osp.edpm.edpm_network_config" diff --git a/roles/edpm_network_config/molecule/nmstate/dummy_config.j2 b/roles/edpm_network_config/molecule/nmstate/dummy_config.j2 new file mode 100644 index 000000000..85069f4bf --- /dev/null +++ b/roles/edpm_network_config/molecule/nmstate/dummy_config.j2 @@ -0,0 +1,7 @@ +--- +interfaces: +- name: dummy0 +type: dummy +state: down +ipv4: + enabled: false diff --git a/roles/edpm_network_config/tasks/main.yml b/roles/edpm_network_config/tasks/main.yml index 7849c4f1d..a687bbd47 100644 --- a/roles/edpm_network_config/tasks/main.yml +++ b/roles/edpm_network_config/tasks/main.yml @@ -36,6 +36,9 @@ name: NetworkManager state: restarted when: nm_ovs_status.changed + - name: Render network_config variable + ansible.builtin.set_fact: + network_config: "{{ lookup('template', edpm_network_config_nmstate_template ) }}" - name: Load system-roles.network tasks [nmstate] ansible.builtin.include_role: name: "{{ systemrolename }}" diff --git a/roles/edpm_network_config/templates/system_role_nmstate/single_nic_vlans.j2 b/roles/edpm_network_config/templates/system_role_nmstate/single_nic_vlans.j2 new file mode 100644 index 000000000..a1ecb6e31 --- /dev/null +++ b/roles/edpm_network_config/templates/system_role_nmstate/single_nic_vlans.j2 @@ -0,0 +1,58 @@ +--- +{% set mtu_list = [ctlplane_mtu] %} +{% for network in role_networks %} +{{ mtu_list.append(lookup('vars', networks_lower[network] ~ '_mtu')) }} +{%- endfor %} +{% set min_viable_mtu = mtu_list | max %} +dns-resolver: + config: + search: {{ dns_search_domains }} + server: {{ ctlplane_dns_nameservers }} +interfaces: + - name: {{ neutron_public_interface_name }} + type: ethernet + state: up + - name: {{ neutron_physical_bridge_name }} + type: ovs-interface + state: up + mtu: {{ min_viable_mtu }} + ipv4: + enabled: true + address: + - ip: {{ ctlplane_ip }} + prefix-length: {{ ctlplane_subnet_cidr }} +{% for network in role_networks %} + - name: {{ "vlan" ~ lookup('vars', networks_lower[network] ~ '_vlan_id') }} + type: ovs-interface + state: up + mtu: {{ lookup('vars', networks_lower[network] ~ '_mtu') }} + ipv4: + enabled: true + address: + - ip: {{ lookup('vars', networks_lower[network] ~ '_ip') }} + prefix-length: {{ lookup('vars', networks_lower[network] ~ '_cidr') }} +{% endfor %} + - name: {{ neutron_physical_bridge_name }} + type: ovs-bridge + bridge: + options: + fail-mode: standalone + port: + - name: {{ neutron_public_interface_name }} + - name: {{ neutron_physical_bridge_name }} +{% for network in role_networks %} + - name: {{ "vlan" ~ lookup('vars', networks_lower[network] ~ '_vlan_id') }} + vlan: + mode: access + tag: {{ lookup('vars', networks_lower[network] ~ '_vlan_id') }} +{% endfor %} +routes: + config: + - destination: {{ ctlplane_host_routes.ip_netmask }} + next-hop-address: {{ ctlplane_host_routes.next_hop }} + next-hop-interface: {{ neutron_physical_bridge_name }} +{% for network in role_neworks %} + - destination: {{ lookup('vars', networks_lower[network] ~ '_host_routes').ip_netmask }} + next-hop-address: {{ lookup('vars', networks_lower[network] ~ '_host_routes').next_hop }} + next-hop-interface: {{ "vlan" ~ lookup('vars', networks_lower[network] ~ '_vlan_id') }} +{% endfor %}