Only add host entries for role_networks

When network isolastion was added there was no have
composable networks and no jinja2 generated heat
templates. Because of this the "standard" networks
was always included, but the port template was
overridden to use the ctlplane's ip address for
disabled networks.

The result is that we have kept host entries for
networks that are irrelevant for some roles. This
was fixed in https://review.opendev.org/614457 but
re-intruduced in tripleo-ansibe.

This fixes the tripleo_hosts_entries role to only
write host entries for networks relavant to the
tripleo role.

Related-Bug: #1842001
Related-Bug: #1800811
Change-Id: I2c8f0eb33be26ebe6d4077b25de47c2b2ab1fca0
(cherry picked from commit 997cb781bd)
This commit is contained in:
Harald Jensås 2020-02-29 18:43:57 +01:00
parent 00cb5fcb31
commit 0c9a9afbf2
2 changed files with 9 additions and 2 deletions

View File

@ -44,9 +44,13 @@ provisioner:
tripleo_hosts_entries_extra_hosts_entries: []
tripleo_hosts_entries_vip_hosts_entries: []
cloud_domain: localdomain
enabled_networks:
- ctlplane
- InternalApi
role_networks:
- ctlplane
- InternalApi
- DisabledNet
networks:
ctlplane:
name_lower: ctlplane

View File

@ -38,8 +38,11 @@
{% for host in groups['overcloud'] %}
{{ hostvars[host][hostvars[host]['hostname_resolve_network'] ~ '_ip'] ~ ' ' ~
host ~ '.' ~ cloud_domain ~ ' ' ~ host }}
{% if role_networks is not none %}
{% for network in role_networks | default([]) %}
{# ## NOTE(hjensas): The Undercloud Minion has no networks, need to check for that here. -#}
{% if hostvars[host]['role_networks'] is not none -%}
{% set _role_networks = hostvars[host]['role_networks'] | default ([]) -%}
{% set _networks = (enabled_networks | default([])) | intersect(_role_networks) -%}
{% for network in _networks -%}
{{ hostvars[host][networks[network]['name_lower'] ~ '_ip'] ~ ' ' ~
host ~ '.' ~ network.lower() ~ '.' ~ cloud_domain ~ ' ' ~
host ~ '.' ~ network.lower() }}