Networks may be none
If the network vars are defined but not lists, the filters and loops
fail in ansible. We need to check that vars exist and that they aren't
none prior to using them.
Change-Id: I648caf97b532c65a0b1e12e8b27be9997a69780d
Closes-Bug: #1855149
(cherry picked from commit f5c93fa2f1
)
This commit is contained in:
parent
7c43643326
commit
3b092215df
@ -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 %}
|
||||
|
@ -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 }}
|
||||
|
@ -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 %}
|
||||
|
Loading…
Reference in New Issue
Block a user