From 4697301965351558331787a819ae60040885ba0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Jeanneret?= Date: Thu, 6 Feb 2020 09:43:46 +0100 Subject: [PATCH] Also use enabled_networks Since we need to generate /etc/hosts on the undercloud as well[1], we have to use the enabled_networks in addition to role_networks, else we might lack some entries on the overcloud nodes, namely the internalapi part. It also makes the generated file a bit less "full of blank", using the "-" flag in some specific places. [1] https://review.opendev.org/705634 Change-Id: Ie942e25ed3501cd4988597ea5dd8d1a17eceec67 Related-Bug: #1861782 --- .../tripleo_hosts_entries/tasks/main.yml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/tripleo_ansible/roles/tripleo_hosts_entries/tasks/main.yml b/tripleo_ansible/roles/tripleo_hosts_entries/tasks/main.yml index 400f3dbba..d0944d493 100644 --- a/tripleo_ansible/roles/tripleo_hosts_entries/tasks/main.yml +++ b/tripleo_ansible/roles/tripleo_hosts_entries/tasks/main.yml @@ -31,26 +31,27 @@ run_once: true set_fact: tripleo_hosts_entries_block: | - {{ tripleo_hosts_entries_undercloud_hosts_entries | join('') }} + {{ tripleo_hosts_entries_undercloud_hosts_entries | default([]) | join('') }} - {{ tripleo_hosts_entries_vip_hosts_entries | join('') }} + {{ tripleo_hosts_entries_vip_hosts_entries | default([]) | join('') }} - {% for host in groups['overcloud'] %} + {% 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([]) %} + {% if role_networks is not none -%} + {% set _networks = (enabled_networks | default([])) | union(role_networks | default([])) -%} + {% for network in _networks -%} {{ hostvars[host][networks[network]['name_lower'] ~ '_ip'] ~ ' ' ~ host ~ '.' ~ network.lower() ~ '.' ~ cloud_domain ~ ' ' ~ host ~ '.' ~ network.lower() }} - {% endfor %} - {% endif %} + {% endfor -%} + {% endif -%} {{ hostvars[host]['ctlplane_ip'] ~ ' ' ~ host ~ '.ctlplane' ~ '.' ~ cloud_domain ~ ' ' ~ host ~ '.ctlplane' }} - {% endfor %} + {% endfor -%} - {{ tripleo_hosts_entries_extra_hosts_entries | join('') }} + {{ tripleo_hosts_entries_extra_hosts_entries | default([]) | join('') }} tags: - tripleo_hosts_entries