From 81738cda4d02d7fc953b921f9dfa84900e299b21 Mon Sep 17 00:00:00 2001 From: Alex Schultz Date: Tue, 23 Jul 2019 10:47:02 -0600 Subject: [PATCH] Skip processing network info if not defined If role_networks or network_cidrs is not defined, the jinja parsing fails because NoneType is not iterable when doing a 'if value in none_type_var' Change-Id: I477f0b840b2a0d2646ba947a88f5264d330ea4eb Closes-Bug: #1837644 --- roles/tripleo-hieradata/templates/fqdn.j2 | 4 +++- roles/tripleo-hieradata/templates/net_ip_map.j2 | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/roles/tripleo-hieradata/templates/fqdn.j2 b/roles/tripleo-hieradata/templates/fqdn.j2 index 84abe5a27..3d7af4341 100644 --- a/roles/tripleo-hieradata/templates/fqdn.j2 +++ b/roles/tripleo-hieradata/templates/fqdn.j2 @@ -1,11 +1,13 @@ { "fqdn_ctlplane": "{{ inventory_hostname ~ '.ctlplane.' ~ cloud_domain }}", - "fqdn_canonical": "{{ inventory_hostname ~ '.' ~ cloud_domain }}"{% if enabled_networks | length > 0 and role_networks | length > 0 %},{% endif %} + "fqdn_canonical": "{{ inventory_hostname ~ '.' ~ cloud_domain }}"{% if enabled_networks | length > 0 and role_networks and role_networks | length > 0 %},{% endif %} +{% if role_networks %} {% for network in enabled_networks %} {% if network in role_networks %} "fqdn_{{ networks[network]['name_lower'] }}": "{{ inventory_hostname ~ '.' ~ network | lower ~ '.' ~ cloud_domain }}" {%- endif %}{% if not loop.last and loop.nextitem | default("") in role_networks %}, {% endif %} {%- endfor %} +{% endif %} } diff --git a/roles/tripleo-hieradata/templates/net_ip_map.j2 b/roles/tripleo-hieradata/templates/net_ip_map.j2 index cc4921e50..4795819cc 100644 --- a/roles/tripleo-hieradata/templates/net_ip_map.j2 +++ b/roles/tripleo-hieradata/templates/net_ip_map.j2 @@ -3,7 +3,7 @@ "ctlplane_subnet": "{{ ctlplane_ip ~ '/' ~ ctlplane_subnet_cidr }}", "ctlplane_uri": "{{ ctlplane_ip | ipwrap }}"{% if enabled_networks | length > 0 %},{% endif %} {%- for network in enabled_networks %} - {%- if network ~ '_cidr' in network_cidrs %} + {%- if network_cidrs and network ~ '_cidr' in network_cidrs %} "{{ networks[network]['name'] }}": "{{ hostvars[inventory_hostname][networks[network]['name'] ~ '_ip'] }}", "{{ networks[network]['name'] }}_subnet": "{{ hostvars[inventory_hostname][networks[network]['name'] ~ '_ip'] ~ '/' ~ network_cidrs[network ~ '_cidr'] }}", "{{ networks[network]['name'] }}_uri": "{{ hostvars[inventory_hostname][networks[network]['name'] ~ '_ip'] | ipwrap }}"{% if not loop.last %},{% endif %}