Browse Source

Restore network_data net order nicX contract

With the Heat multi-nic example templates the
loop.index was used to set the nicX for each
interface, and ordered iteration was done over
all networks in network_data.yaml. The ctlplane
was always nic1, then nic2 was mapped to the
first network in the network_data.yaml definition.

When converting multi-nic templates to ansible
the ordering contract between network_data.yaml
and the nicX for each network was broken because
iteration happens only over networks associated
with the role.

This change restores the ordering contract in
the multi-nic templates by iterating over the
'networks_all' group_var which holds all enabled
networks in the order of apperance in
network_data.yaml.

Depends-On: https://review.opendev.org/763497
Closes-Bug: #1904894
Change-Id: I9d2767d7ce4f24645684fde6044c38a4b920dbb1
changes/96/763496/6
Harald Jensås 2 years ago
parent
commit
15c280787e
  1. 6
      tripleo_ansible/roles/tripleo_network_config/templates/multiple_nics/multiple_nics.j2
  2. 6
      tripleo_ansible/roles/tripleo_network_config/templates/multiple_nics/multiple_nics_dpdk.j2
  3. 41
      tripleo_ansible/roles/tripleo_network_config/templates/multiple_nics/multiple_nics_dvr.j2
  4. 6
      tripleo_ansible/roles/tripleo_network_config/templates/multiple_nics_vlans/multiple_nics_vlans.j2
  5. 6
      tripleo_ansible/roles/tripleo_network_config/templates/multiple_nics_vlans/multiple_nics_vlans_dpdk.j2
  6. 47
      tripleo_ansible/roles/tripleo_network_config/templates/multiple_nics_vlans/multiple_nics_vlans_dvr.j2

6
tripleo_ansible/roles/tripleo_network_config/templates/multiple_nics/multiple_nics.j2

@ -9,8 +9,8 @@ network_config:
use_dhcp: false
addresses:
- ip_netmask: {{ ctlplane_ip }}/{{ ctlplane_subnet_cidr }}
{% for network in role_networks if network not in networks_skip_config %}
{% if network not in ["External", "Tenant"] %}
{% for network in networks_all if network not in networks_skip_config %}
{% if network not in ["External", "Tenant"] and network in role_networks %}
- type: interface
name: nic{{ loop.index +1 }}
mtu: {{ lookup('vars', networks_lower[network] ~ '_mtu') }}
@ -19,7 +19,7 @@ network_config:
- ip_netmask:
{{ lookup('vars', networks_lower[network] ~ '_ip') }}/{{ lookup('vars', networks_lower[network] ~ '_cidr') }}
routes: {{ lookup('vars', networks_lower[network] ~ '_host_routes') }}
{% elif 'external_bridge' in role_tags %}
{% elif network in role_networks or 'external_bridge' in role_tags %}
- type: ovs_bridge
{% if network == 'External' %}
name: {{ neutron_physical_bridge_name }}

6
tripleo_ansible/roles/tripleo_network_config/templates/multiple_nics/multiple_nics_dpdk.j2

@ -10,8 +10,8 @@ network_config:
addresses:
- ip_netmask: {{ ctlplane_ip }}/{{ ctlplane_subnet_cidr }}
{% set nics_used = [1] %}
{% for network in role_networks if network not in networks_skip_config %}
{% if network not in ["External", "Tenant"] %}
{% for network in networks_all if network not in networks_skip_config %}
{% if network not in ["External", "Tenant"] and network in role_networks %}
- type: interface
name: nic{{ loop.index +1 }}
mtu: {{ lookup('vars', networks_lower[network] ~ '_mtu') }}
@ -20,7 +20,7 @@ network_config:
- ip_netmask:
{{ lookup('vars', networks_lower[network] ~ '_ip') }}/{{ lookup('vars', networks_lower[network] ~ '_cidr') }}
routes: {{ lookup('vars', networks_lower[network] ~ '_host_routes') }}
{% elif 'external_bridge' in role_tags %}
{% elif network in role_networks or 'external_bridge' in role_tags %}
- type: ovs_bridge
{% if network == 'External' %}
name: {{ neutron_physical_bridge_name }}

41
tripleo_ansible/roles/tripleo_network_config/templates/multiple_nics/multiple_nics_dvr.j2

@ -9,9 +9,25 @@ network_config:
use_dhcp: false
addresses:
- ip_netmask: {{ ctlplane_ip }}/{{ ctlplane_subnet_cidr }}
{% set nics_used = [1] %}
{% for network in role_networks if network not in networks_skip_config %}
{% if network not in ["External", "Tenant"] %}
{% for network in networks_all if network not in networks_skip_config|default([]) %}
{% if network == 'External' %}
- type: ovs_bridge
name: {{ neutron_physical_bridge_name }}
mtu: {{ lookup('vars', networks_lower[network] ~ '_mtu') }}
dns_servers: {{ ctlplane_dns_nameservers }}
use_dhcp: false
{% if network in role_networks %}
addresses:
- ip_netmask:
{{ lookup('vars', networks_lower[network] ~ '_ip') }}/{{ lookup('vars', networks_lower[network] ~ '_cidr') }}
routes: {{ lookup('vars', networks_lower[network] ~ '_host_routes') }}
{% endif %}
members:
- type: interface
name: nic{{ loop.index +1 }}
mtu: {{ lookup('vars', networks_lower[network] ~ '_mtu') }}
primary: true
{% elif network not in ["External", "Tenant"] and network in role_networks %}
- type: interface
name: nic{{ loop.index +1 }}
mtu: {{ lookup('vars', networks_lower[network] ~ '_mtu') }}
@ -20,7 +36,7 @@ network_config:
- ip_netmask:
{{ lookup('vars', networks_lower[network] ~ '_ip') }}/{{ lookup('vars', networks_lower[network] ~ '_cidr') }}
routes: {{ lookup('vars', networks_lower[network] ~ '_host_routes') }}
{% elif network == 'Tenant' %}
{% elif network == 'Tenant' and network in role_networks %}
- type: ovs_bridge
name: {{ 'br-' ~ networks_lower[network] }}
mtu: {{ lookup('vars', networks_lower[network] ~ '_mtu') }}
@ -37,21 +53,4 @@ network_config:
use_dhcp: false
primary: true
{% endif %}
{% set _ = nics_used.append(loop.index) %}
{% endfor %}
- type: ovs_bridge
name: {{ neutron_physical_bridge_name }}
mtu: {{ lookup('vars', networks_lower['External'] ~ '_mtu') }}
dns_servers: {{ ctlplane_dns_nameservers }}
use_dhcp: false
{% if 'External' in role_networks %}
addresses:
- ip_netmask:
{{ lookup('vars', networks_lower['External'] ~ '_ip') }}/{{ lookup('vars', networks_lower['External'] ~ '_cidr') }}
routes: {{ lookup('vars', networks_lower['External'] ~ '_host_routes') }}
{% endif %}
members:
- type: interface
name: nic{{nics_used[-1] + 1}}
mtu: {{ lookup('vars', networks_lower['External'] ~ '_mtu') }}
primary: true

6
tripleo_ansible/roles/tripleo_network_config/templates/multiple_nics_vlans/multiple_nics_vlans.j2

@ -9,8 +9,8 @@ network_config:
use_dhcp: false
addresses:
- ip_netmask: {{ ctlplane_ip }}/{{ ctlplane_subnet_cidr }}
{% for network in role_networks if network not in networks_skip_config %}
{% if network not in ["External", "Tenant"] %}
{% for network in networks_all if network not in networks_skip_config %}
{% if network not in ["External", "Tenant"] and network in role_networks %}
- type: interface
name: nic{{ loop.index + 1 }}
mtu: {{ lookup('vars', networks_lower[network] ~ '_mtu') }}
@ -23,7 +23,7 @@ network_config:
- ip_netmask:
{{ lookup('vars', networks_lower[network] ~ '_ip') }}/{{ lookup('vars', networks_lower[network] ~ '_cidr') }}
routes: {{ lookup('vars', networks_lower[network] ~ '_host_routes') }}
{% elif 'external_bridge' in role_tags %}
{% elif network in role_networks or 'external_bridge' in role_tags %}
- type: ovs_bridge
{% if network == 'External' %}
name: {{ neutron_physical_bridge_name }}

6
tripleo_ansible/roles/tripleo_network_config/templates/multiple_nics_vlans/multiple_nics_vlans_dpdk.j2

@ -10,8 +10,8 @@ network_config:
addresses:
- ip_netmask: {{ ctlplane_ip }}/{{ ctlplane_subnet_cidr }}
{% set nics_used = [1] %}
{% for network in role_networks if network not in networks_skip_config %}
{% if network not in ["External", "Tenant"] %}
{% for network in networks_all if network not in networks_skip_config %}
{% if network not in ["External", "Tenant"] and network in role_networks %}
- type: interface
name: nic{{ loop.index + 1 }}
mtu: {{ lookup('vars', networks_lower[network] ~ '_mtu') }}
@ -24,7 +24,7 @@ network_config:
- ip_netmask:
{{ lookup('vars', networks_lower[network] ~ '_ip') }}/{{ lookup('vars', networks_lower[network] ~ '_cidr') }}
routes: {{ lookup('vars', networks_lower[network] ~ '_host_routes') }}
{% elif 'external_bridge' in role_tags %}
{% elif network in role_networks or 'external_bridge' in role_tags %}
- type: ovs_bridge
{% if network == 'External' %}
name: {{ neutron_physical_bridge_name }}

47
tripleo_ansible/roles/tripleo_network_config/templates/multiple_nics_vlans/multiple_nics_vlans_dvr.j2

@ -9,9 +9,28 @@ network_config:
use_dhcp: false
addresses:
- ip_netmask: {{ ctlplane_ip }}/{{ ctlplane_subnet_cidr }}
{% set nics_used = [1] %}
{% for network in role_networks if network not in networks_skip_config %}
{% if network not in ["External", "Tenant"] %}
{% for network in networks_all if network not in networks_skip_config|default([]) %}
{% if network == 'External' %}
- type: ovs_bridge
name: {{ neutron_physical_bridge_name }}
mtu: {{ lookup('vars', networks_lower[network] ~ '_mtu') }}
dns_servers: {{ ctlplane_dns_nameservers }}
use_dhcp: false
members:
- type: interface
name: nic{{ loop.index + 1 }}
mtu: {{ lookup('vars', networks_lower[network] ~ '_mtu') }}
primary: true
{% if network in role_networks %}
- type: vlan
mtu: {{ lookup('vars', networks_lower[network] ~ '_mtu') }}
vlan_id: {{ lookup('vars', networks_lower[network] ~ '_vlan_id') }}
addresses:
- ip_netmask:
{{ lookup('vars', networks_lower[network] ~ '_ip') }}/{{ lookup('vars', networks_lower[network] ~ '_cidr') }}
routes: {{ lookup('vars', networks_lower[network] ~ '_host_routes') }}
{% endif %}
{% elif network not in ["External", "Tenant"] and network in role_networks %}
- type: interface
name: nic{{ loop.index + 1 }}
mtu: {{ lookup('vars', networks_lower[network] ~ '_mtu') }}
@ -24,7 +43,7 @@ network_config:
- ip_netmask:
{{ lookup('vars', networks_lower[network] ~ '_ip') }}/{{ lookup('vars', networks_lower[network] ~ '_cidr') }}
routes: {{ lookup('vars', networks_lower[network] ~ '_host_routes') }}
{% elif network == 'Tenant' %}
{% elif network == 'Tenant' and network in role_networks %}
- type: ovs_bridge
name: {{ 'br-' ~ networks_lower[network] }}
mtu: {{ lookup('vars', networks_lower[network] ~ '_mtu') }}
@ -44,24 +63,4 @@ network_config:
{{ lookup('vars', networks_lower[network] ~ '_ip') }}/{{ lookup('vars', networks_lower[network] ~ '_cidr') }}
routes: {{ lookup('vars', networks_lower[network] ~ '_host_routes') }}
{% endif %}
{% set _ = nics_used.append(loop.index) %}
{% endfor %}
- type: ovs_bridge
name: {{ neutron_physical_bridge_name }}
mtu: {{ lookup('vars', networks_lower['External'] ~ '_mtu') }}
dns_servers: {{ ctlplane_dns_nameservers }}
use_dhcp: false
members:
- type: interface
name: nic{{nics_used[-1] + 1}}
mtu: {{ lookup('vars', networks_lower['External'] ~ '_mtu') }}
primary: true
{% if 'External' in role_networks %}
- type: vlan
mtu: {{ lookup('vars', networks_lower['External'] ~ '_mtu') }}
vlan_id: {{ lookup('vars', networks_lower['External'] ~ '_vlan_id') }}
addresses:
- ip_netmask:
{{ lookup('vars', networks_lower['External'] ~ '_ip') }}/{{ lookup('vars', networks_lower['External'] ~ '_cidr') }}
routes: {{ lookup('vars', networks_lower['External'] ~ '_host_routes') }}
{% endif %}

Loading…
Cancel
Save