Get the CIDR of the neutron port for NetworkConfig

Since GroupVars moved to overcloud.j2.yaml in
https://review.opendev.org/677218 the CIDR set in
'{{network.name_lower}}_cidr' in groupvars is limited
to one of the subnets on the network.

When a network have multiple subnets with different
subnet prefixes, this becomes a problem as nodes are
configured with the from subnet mask.

This change moves them to AnsibleHostVars.

Closes-Bug: #1895899
Change-Id: I4e4e5b1195d17f59c825a3f7df73920921e1f86e
This commit is contained in:
Harald Jensås 2020-09-17 01:02:30 +02:00 committed by Rabi Mishra
parent 90c5e52461
commit cd53ae79c7
3 changed files with 26 additions and 25 deletions

View File

@ -918,37 +918,12 @@ resources:
type: OS::Heat::Value type: OS::Heat::Value
properties: properties:
value: value:
ctlplane_subnet_cidr:
yaql:
expression: coalesce($.data, []).where(not isEmpty($)).first().split('/')[-1]
data:
if:
- ctlplane_subnet_cidr_set
- [{get_param: ControlPlaneSubnetCidr}]
- {get_attr: [ControlVirtualIP, network, tags]}
network_cidrs:
{%- for network in networks %}
{%- if network.enabled|default(true) and network.name in role.networks|default([]) %}
{{network.name}}_cidr:
yaql:
expression: coalesce($.data, []).where(not isEmpty($)).first().split('/')[-1]
data: {get_attr: [Networks, net_cidr_map, {{network.name_lower}}]}
{%- endif %}
{%- endfor %}
role_networks: role_networks:
{%- for network in networks %} {%- for network in networks %}
{%- if network.enabled|default(true) and network.name in role.networks|default([]) %} {%- if network.enabled|default(true) and network.name in role.networks|default([]) %}
- {{network.name}} - {{network.name}}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{%- for network in networks %}
{%- if network.enabled|default(true) and network.name in role.networks|default([]) %}
{{network.name_lower}}_cidr:
yaql:
expression: coalesce($.data, []).where(not isEmpty($)).first().split('/')[-1]
data: {get_attr: [Networks, net_cidr_map, {{network.name_lower}}]}
{% endif %}
{% endfor %}
service_metadata_settings: {get_attr: [{{role.name}}ServiceChainRoleData, value, service_metadata_settings]} service_metadata_settings: {get_attr: [{{role.name}}ServiceChainRoleData, value, service_metadata_settings]}
{% endfor %} {% endfor %}

View File

@ -574,10 +574,24 @@ resources:
properties: properties:
type: json type: json
value: value:
ctlplane_subnet_cidr:
if:
- ctlplane_subnet_cidr_set
- {get_param: ControlPlaneSubnetCidr}
- yaql:
expression: str("{0}".format($.data).split("/")[-1])
data: {get_attr: [{{server_resource_name}}, addresses, ctlplane, 0, subnets, 0, cidr]}
{%- for network in networks %} {%- for network in networks %}
{%- if network.enabled|default(true) and network.name in role.networks|default([]) %} {%- if network.enabled|default(true) and network.name in role.networks|default([]) %}
{{network.name_lower}}_cidr: {get_attr: [{{network.name}}Port, cidr]}
fqdn_{{network.name_lower}}: {get_attr: [NetHostMap, value, {{network.name_lower}}, fqdn]} fqdn_{{network.name_lower}}: {get_attr: [NetHostMap, value, {{network.name_lower}}, fqdn]}
{%- endif %} {%- endif %}
{%- endfor %}
network_cidrs:
{%- for network in networks %}
{%- if network.enabled|default(true) and network.name in role.networks|default([]) %}
{{network.name}}_cidr: {get_attr: [{{network.name}}Port, cidr]}
{%- endif %}
{%- endfor %} {%- endfor %}
fqdn_ctlplane: {get_attr: [NetHostMap, value, ctlplane, fqdn]} fqdn_ctlplane: {get_attr: [NetHostMap, value, ctlplane, fqdn]}
fqdn_canonical: {get_attr: [NetHostMap, value, canonical, fqdn]} fqdn_canonical: {get_attr: [NetHostMap, value, canonical, fqdn]}

View File

@ -0,0 +1,12 @@
---
fixes:
- |
Ansible GroupVars incorrectly keept a single subnet prefix per-network.
This caused a problem when multiple subnets using different subnet
prefixes where defined. Resulting in the wrong subnet prefix being
referenced in the NetworkConfig for roles.
AnsibleHostVars stores networks subnet prefixes instead.
See bug: `1895899
<https://bugs.launchpad.net/tripleo/+bug/1895899>`_.