Merge "Networks may be none"

This commit is contained in:
Zuul 2019-12-06 22:03:08 +00:00 committed by Gerrit Code Review
commit e880fa6e11
3 changed files with 7 additions and 4 deletions

View File

@ -1,9 +1,9 @@
{% set fqdn = {} %}
{% set _ = fqdn.__setitem__('fqdn_ctlplane', (inventory_hostname ~ '.ctlplane.' ~ cloud_domain)) %}
{% set _ = fqdn.__setitem__('fqdn_canonical', (inventory_hostname ~ '.' ~ cloud_domain)) %}
{% if role_networks is defined %}
{% if enabled_networks is defined and enabled_networks %}
{% for network in enabled_networks %}
{% if network in role_networks %}
{% if role_networks is defined and role_networks and network in role_networks %}
{% set _ = fqdn.__setitem__(('fqdn_' ~ networks[network]['name_lower']), (inventory_hostname ~ '.' ~ network | lower ~ '.' ~ cloud_domain)) %}
{% endif %}
{% endfor %}

View File

@ -6,8 +6,9 @@
{% set _ = net_ip_map.__setitem__('ctlplane_subnet', ctlplane_ip ~ '/' ~ ctlplane_subnet_cidr) %}
{% endif %}
{% endif %}
{% if enabled_networks is defined and enabled_networks %}
{% for network in enabled_networks %}
{% if network_cidrs is defined and ((network ~ '_cidr') in network_cidrs) %}
{% if network_cidrs is defined and network_cidrs and ((network ~ '_cidr') in network_cidrs) %}
{% set _ = net_ip_map.__setitem__(networks[network]['name'], (hostvars[inventory_hostname][networks[network]['name'] ~ '_ip'])) %}
{% set _ = net_ip_map.__setitem__((networks[network]['name'] ~ '_subnet'), (hostvars[inventory_hostname][networks[network]['name'] ~ '_ip'] ~ '/' ~ network_cidrs[network ~ '_cidr'])) %}
{% set _ = net_ip_map.__setitem__((networks[network]['name'] ~ '_uri'), (hostvars[inventory_hostname][networks[network]['name'] ~ '_ip'] | ipwrap)) %}
@ -18,5 +19,6 @@
{% set _ = net_ip_map.__setitem__((networks[network]['name'] ~ '_uri'), "") %}
{% endif %}
{% endfor %}
{% endif %}
{# RENDER #}
{{ net_ip_map | to_nice_json }}

View File

@ -49,7 +49,8 @@
ssh_known_hosts_lines: |-
{%- for host in groups['overcloud'] | intersect(play_hosts) %}
[{{ ctlplane_ip }}]*,[{{ host }}.{{ cloud_domain }}]*,[{{ host }}]*
{%- if enabled_networks | length > 0 and hostvars[host]['role_networks'] is defined and hostvars[host]['role_networks'] | length > 0 %},
{%- if (enabled_networks and enabled_networks | length > 0 and 'role_networks' in hostvars[host]
and hostvars[host]['role_networks'] and hostvars[host]['role_networks'] | length > 0) %},
{%- for network in enabled_networks %}
{%- if network in hostvars[host]['role_networks'] %}
[{{ hostvars[host][networks[network]['name'] ~ '_ip'] }}]*,[{{ host }}.{{ network.lower() }}]*,{% if 1 %}{% endif %}