From 9bbd4fe553cc53f36a670a4f16badf2480526c01 Mon Sep 17 00:00:00 2001 From: ramishra Date: Wed, 12 May 2021 08:46:56 +0530 Subject: [PATCH] Don't assume role has default_route_networks/tags This broken after new jinja release. NOTE: This included nic config updates as well. And changes for role.tags. Co-Authored-By: Alex Schultz Closes-Bug: #1928145 Change-Id: I9cbdcf289bae96f8ea7867e1cec365a9a07019ca (cherry picked from commit 4af0c6ccac891fceff68a92e05c1734e27fbc1e0) --- common/deploy-steps.j2 | 2 +- .../octavia/octavia-deployment-config.j2.yaml | 2 +- environments/network-isolation-v6-all.j2.yaml | 2 +- .../config/2-linux-bonds-vlans/role.role.j2.yaml | 8 ++++---- network/config/bond-with-vlans/role.role.j2.yaml | 6 +++--- .../config/multiple-nics-vlans/role.role.j2.yaml | 14 ++++++++------ network/config/multiple-nics/role.role.j2.yaml | 12 +++++++----- .../role.role.j2.yaml | 4 ++-- network/config/single-nic-vlans/role.role.j2.yaml | 4 ++-- overcloud-resource-registry-puppet.j2.yaml | 2 +- overcloud.j2.yaml | 2 +- puppet/role.role.j2.yaml | 2 +- 12 files changed, 32 insertions(+), 28 deletions(-) diff --git a/common/deploy-steps.j2 b/common/deploy-steps.j2 index 0addf79b4a..1e23f3147d 100644 --- a/common/deploy-steps.j2 +++ b/common/deploy-steps.j2 @@ -7,7 +7,7 @@ {%- endif -%} {%- set primary_role = [enabled_roles[0]] -%} {%- for role in enabled_roles -%} - {%- if 'primary' in role.tags and 'controller' in role.tags -%} + {%- if role.tags is defined and 'primary' in role.tags and 'controller' in role.tags -%} {%- set _ = primary_role.pop() -%} {%- set _ = primary_role.append(role) -%} {%- endif -%} diff --git a/deployment/octavia/octavia-deployment-config.j2.yaml b/deployment/octavia/octavia-deployment-config.j2.yaml index 57048221f9..68727a2d8a 100644 --- a/deployment/octavia/octavia-deployment-config.j2.yaml +++ b/deployment/octavia/octavia-deployment-config.j2.yaml @@ -1,6 +1,6 @@ heat_template_version: rocky {%- set octavia_standalone=[] -%} -{%- for role in roles if 'standalone' in role.tags -%} +{%- for role in roles if role.tags is defined and 'standalone' in role.tags -%} {% if octavia_standalone.append('1') %}{% endif %} {%- endfor %} diff --git a/environments/network-isolation-v6-all.j2.yaml b/environments/network-isolation-v6-all.j2.yaml index be8327c58b..0cc15d4894 100644 --- a/environments/network-isolation-v6-all.j2.yaml +++ b/environments/network-isolation-v6-all.j2.yaml @@ -3,7 +3,7 @@ # or update. {%- set primary_role = [roles[0]] -%} {%- for role in roles -%} - {%- if 'primary' in role.tags and 'controller' in role.tags -%} + {%- if role.tags is defined and 'primary' in role.tags and 'controller' in role.tags -%} {%- set _ = primary_role.pop() -%} {%- set _ = primary_role.append(role) -%} {%- endif -%} diff --git a/network/config/2-linux-bonds-vlans/role.role.j2.yaml b/network/config/2-linux-bonds-vlans/role.role.j2.yaml index 5456bd6321..0c22a5e656 100644 --- a/network/config/2-linux-bonds-vlans/role.role.j2.yaml +++ b/network/config/2-linux-bonds-vlans/role.role.j2.yaml @@ -59,7 +59,7 @@ parameters: guaranteed to pass through the data path of the segments in the {{network.name}} network. type: number -{%- if network.name in role.default_route_networks %} +{%- if role.default_route_networks is defined and network.name in role.default_route_networks %} {{network.name}}InterfaceDefaultRoute: default: '' description: default route for the {{network.name_lower}} network @@ -200,7 +200,7 @@ resources: routes: list_concat_unique: - get_param: {{network.name}}InterfaceRoutes - {%- if network.name in role.default_route_networks %} + {%- if role.default_route_networks is defined and network.name in role.default_route_networks %} - - default: true next_hop: get_param: {{network.name}}InterfaceDefaultRoute @@ -241,7 +241,7 @@ resources: routes: list_concat_unique: - get_param: {{network.name}}InterfaceRoutes - {%- if network.name in role.default_route_networks %} + {%- if role.default_route_networks is defined and network.name in role.default_route_networks %} - - default: true next_hop: get_param: {{network.name}}InterfaceDefaultRoute @@ -262,7 +262,7 @@ resources: routes: list_concat_unique: - get_param: {{network.name}}InterfaceRoutes - {%- if network.name in role.default_route_networks %} + {%- if role.default_route_networks is defined and network.name in role.default_route_networks %} - - default: true next_hop: get_param: {{network.name}}InterfaceDefaultRoute diff --git a/network/config/bond-with-vlans/role.role.j2.yaml b/network/config/bond-with-vlans/role.role.j2.yaml index a3b7dbced9..972e477e2a 100644 --- a/network/config/bond-with-vlans/role.role.j2.yaml +++ b/network/config/bond-with-vlans/role.role.j2.yaml @@ -57,7 +57,7 @@ parameters: guaranteed to pass through the data path of the segments in the {{network.name}} network. type: number -{%- if network.name in role.default_route_networks %} +{%- if role.default_route_networks is defined and network.name in role.default_route_networks %} {{network.name}}InterfaceDefaultRoute: default: '' description: default route for the {{network.name_lower}} network @@ -184,7 +184,7 @@ resources: routes: list_concat_unique: - get_param: {{network.name}}InterfaceRoutes -{%- if network.name in role.default_route_networks %} +{%- if role.default_route_networks is defined and network.name in role.default_route_networks %} - - default: true next_hop: get_param: {{network.name}}InterfaceDefaultRoute @@ -224,7 +224,7 @@ resources: routes: list_concat_unique: - get_param: {{network.name}}InterfaceRoutes -{%- if network.name in role.default_route_networks %} +{%- if role.default_route_networks is defined and network.name in role.default_route_networks %} - - default: true next_hop: get_param: {{network.name}}InterfaceDefaultRoute diff --git a/network/config/multiple-nics-vlans/role.role.j2.yaml b/network/config/multiple-nics-vlans/role.role.j2.yaml index 39d2abe529..5d091acd49 100644 --- a/network/config/multiple-nics-vlans/role.role.j2.yaml +++ b/network/config/multiple-nics-vlans/role.role.j2.yaml @@ -59,7 +59,7 @@ parameters: guaranteed to pass through the data path of the segments in the {{network.name}} network. type: number -{%- if network.name in role.default_route_networks %} +{%- if role.default_route_networks is defined and network.name in role.default_route_networks %} {{network.name}}InterfaceDefaultRoute: default: '' description: default route for the {{network.name_lower}} network @@ -74,14 +74,16 @@ parameters: from the subnet host_routes attribute. type: json {%- endfor %} -{% for network in networks if network.name == "External" and 'external_bridge' in role.tags and not network.name in _role_networks %} +{% for network in networks if network.name == "External" %} + {% if role.tags is defined and 'external_bridge' in role.tags and not network.name in _role_networks %} {{network.name}}Mtu: default: {{network.mtu|default('1500')}} description: The maximum transmission unit (MTU) size(in bytes) that is guaranteed to pass through the data path of the segments in the {{network.name}} network. type: number -{% endfor %} + {%- endif %} +{%- endfor %} DnsServers: # Override this via parameter_defaults default: [] description: > @@ -155,14 +157,14 @@ resources: routes: list_concat_unique: - get_param: {{network.name}}InterfaceRoutes -{%- if network.name in role.default_route_networks %} +{%- if role.default_route_networks is defined and network.name in role.default_route_networks %} - - default: true next_hop: get_param: {{network.name}}InterfaceDefaultRoute {%- endif %} {%- endif %} {#- We need bridge also for ComputeDVR and Computes with OVN #} -{%- elif network.name in role.networks or 'external_bridge' in role.tags %} +{%- elif network.name in role.networks or (role.tags is defined and 'external_bridge' in role.tags) %} - type: ovs_bridge {%- if network.name == "External" %} name: bridge_name @@ -193,7 +195,7 @@ resources: routes: list_concat_unique: - get_param: {{network.name}}InterfaceRoutes -{%- if network.name in role.default_route_networks %} +{%- if role.default_route_networks is defined and network.name in role.default_route_networks %} - - default: true next_hop: get_param: {{network.name}}InterfaceDefaultRoute diff --git a/network/config/multiple-nics/role.role.j2.yaml b/network/config/multiple-nics/role.role.j2.yaml index 57a5e361cb..b847cbecb1 100644 --- a/network/config/multiple-nics/role.role.j2.yaml +++ b/network/config/multiple-nics/role.role.j2.yaml @@ -59,7 +59,7 @@ parameters: guaranteed to pass through the data path of the segments in the {{network.name}} network. type: number -{%- if network.name in role.default_route_networks %} +{%- if role.default_route_networks is defined and network.name in role.default_route_networks %} {{network.name}}InterfaceDefaultRoute: default: '' description: default route for the {{network.name_lower}} network @@ -74,13 +74,15 @@ parameters: from the subnet host_routes attribute. type: json {%- endfor %} -{% for network in networks if network.name == "External" and 'external_bridge' in role.tags and not network.name in _role_networks %} +{% for network in networks if network.name == "External" %} + {% if role.tags is defined and 'external_bridge' in role.tags and not network.name in _role_networks %} {{network.name}}Mtu: default: {{network.mtu|default('1500')}} description: The maximum transmission unit (MTU) size(in bytes) that is guaranteed to pass through the data path of the segments in the {{network.name}} network. type: number + {%- endif %} {% endfor %} DnsServers: # Override this via parameter_defaults default: [] @@ -149,14 +151,14 @@ resources: routes: list_concat_unique: - get_param: {{network.name}}InterfaceRoutes -{%- if network.name in role.default_route_networks %} +{%- if role.default_route_networks is defined and network.name in role.default_route_networks %} - - default: true next_hop: get_param: {{network.name}}InterfaceDefaultRoute {%- endif %} {%- endif %} {#- We need bridge also for ComputeDVR and Computes with OVN #} -{%- elif network.name in _role_networks or 'external_bridge' in role.tags %} +{%- elif network.name in role.networks or (role.tags is defined and 'external_bridge' in role.tags) %} - type: ovs_bridge {%- if network.name == "External" %} name: bridge_name @@ -175,7 +177,7 @@ resources: routes: list_concat_unique: - get_param: {{network.name}}InterfaceRoutes -{%- if network.name in role.default_route_networks %} +{%- if role.default_route_networks is defined and network.name in role.default_route_networks %} - - default: true next_hop: get_param: {{network.name}}InterfaceDefaultRoute diff --git a/network/config/single-nic-linux-bridge-vlans/role.role.j2.yaml b/network/config/single-nic-linux-bridge-vlans/role.role.j2.yaml index f08a59a02b..eeff01d2fa 100644 --- a/network/config/single-nic-linux-bridge-vlans/role.role.j2.yaml +++ b/network/config/single-nic-linux-bridge-vlans/role.role.j2.yaml @@ -57,7 +57,7 @@ parameters: guaranteed to pass through the data path of the segments in the {{network.name}} network. type: number -{%- if network.name in role.default_route_networks %} +{%- if role.default_route_networks is defined and network.name in role.default_route_networks %} {{network.name}}InterfaceDefaultRoute: default: '' description: default route for the {{network.name_lower}} network @@ -165,7 +165,7 @@ resources: routes: list_concat_unique: - get_param: {{network.name}}InterfaceRoutes -{%- if network.name in role.default_route_networks %} +{%- if role.default_route_networks is defined and network.name in role.default_route_networks %} - - default: true next_hop: get_param: {{network.name}}InterfaceDefaultRoute diff --git a/network/config/single-nic-vlans/role.role.j2.yaml b/network/config/single-nic-vlans/role.role.j2.yaml index 95e2bd57c8..d02ad61dc5 100644 --- a/network/config/single-nic-vlans/role.role.j2.yaml +++ b/network/config/single-nic-vlans/role.role.j2.yaml @@ -57,7 +57,7 @@ parameters: guaranteed to pass through the data path of the segments in the {{network.name}} network. type: number -{%- if network.name in role.default_route_networks %} +{%- if role.default_route_networks is defined and network.name in role.default_route_networks %} {{network.name}}InterfaceDefaultRoute: default: '' description: default route for the {{network.name_lower}} network @@ -160,7 +160,7 @@ resources: routes: list_concat_unique: - get_param: {{network.name}}InterfaceRoutes -{%- if network.name in role.default_route_networks %} +{%- if role.default_route_networks is defined and network.name in role.default_route_networks %} - - default: true next_hop: get_param: {{network.name}}InterfaceDefaultRoute diff --git a/overcloud-resource-registry-puppet.j2.yaml b/overcloud-resource-registry-puppet.j2.yaml index 7615cb3fa9..5512bee8fc 100644 --- a/overcloud-resource-registry-puppet.j2.yaml +++ b/overcloud-resource-registry-puppet.j2.yaml @@ -18,7 +18,7 @@ resource_registry: {%- for network in networks if network.enabled|default(true) and network.name in role.networks|default([]) %} OS::TripleO::{{role.name}}::Ports::{{network.name}}Port: network/ports/noop.yaml {%- endfor %} - {%- if 'external_bridge' in role.tags %} + {%- if role.tags is defined and 'external_bridge' in role.tags %} # Create Neutron external bridge for floating IPs and/or SNAT OS::TripleO::{{role.name}}::Net::SoftwareConfig: net-config-bridge.yaml {%- else %} diff --git a/overcloud.j2.yaml b/overcloud.j2.yaml index 869bd6c9be..451152e8c8 100644 --- a/overcloud.j2.yaml +++ b/overcloud.j2.yaml @@ -1,6 +1,6 @@ {%- set primary_role = [roles[0]] -%} {%- for role in roles -%} - {%- if 'primary' in role.tags and 'controller' in role.tags -%} + {%- if role.tags is defined and 'primary' in role.tags and 'controller' in role.tags -%} {%- set _ = primary_role.pop() -%} {%- set _ = primary_role.append(role) -%} {%- endif -%} diff --git a/puppet/role.role.j2.yaml b/puppet/role.role.j2.yaml index 918bea13e9..b8af2a73df 100644 --- a/puppet/role.role.j2.yaml +++ b/puppet/role.role.j2.yaml @@ -455,7 +455,7 @@ resources: - {get_param: {{network.name}}InterfaceRoutes} - {get_attr: [{{network.name}}Port, host_routes]} {{network.name}}Mtu: {get_attr: [{{network.name}}Port, mtu]} - {%- if network.name in role.default_route_networks %} + {%- if role.default_route_networks is defined and network.name in role.default_route_networks %} {{network.name}}InterfaceDefaultRoute: {get_attr: [{{network.name}}Port, gateway_ip]} {%- endif %} {%- if role.networks is mapping %}