diff --git a/tripleo_ansible/roles/tripleo-hieradata/templates/fqdn.j2 b/tripleo_ansible/roles/tripleo-hieradata/templates/fqdn.j2 index 46618f03b..a6bc9e7ba 100644 --- a/tripleo_ansible/roles/tripleo-hieradata/templates/fqdn.j2 +++ b/tripleo_ansible/roles/tripleo-hieradata/templates/fqdn.j2 @@ -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 %} diff --git a/tripleo_ansible/roles/tripleo-hieradata/templates/net_ip_map.j2 b/tripleo_ansible/roles/tripleo-hieradata/templates/net_ip_map.j2 index 8a5ec864e..99e641e80 100644 --- a/tripleo_ansible/roles/tripleo-hieradata/templates/net_ip_map.j2 +++ b/tripleo_ansible/roles/tripleo-hieradata/templates/net_ip_map.j2 @@ -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 }} diff --git a/tripleo_ansible/roles/tripleo-ssh-known-hosts/tasks/main.yml b/tripleo_ansible/roles/tripleo-ssh-known-hosts/tasks/main.yml index 9c1b40cf5..ded195fdc 100644 --- a/tripleo_ansible/roles/tripleo-ssh-known-hosts/tasks/main.yml +++ b/tripleo_ansible/roles/tripleo-ssh-known-hosts/tasks/main.yml @@ -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 %}