From 75ed35c46a3368c19ff7aa14c13609fdf7008255 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Jeanneret?= Date: Fri, 20 Mar 2020 08:22:11 +0100 Subject: [PATCH] Rework how we push the content in the file Since we allow to pass lists, we can't just use |join(''). In addition, using the multi-line support in YAML via the "|" creates some issues when we want to use |join('\n'): it gets escaped, meaning we end with a one-line content with some \n entries. The present patch ensures that: - generated content is still pushed in a fact to not lose time - static content (lists) is properly treated and outputs correctly Change-Id: I7e520035f24503e59840b34e5b2d9e9966cd6ca4 --- .../roles/tripleo_hosts_entries/tasks/main.yml | 17 ++++++++--------- 1 file changed, 8 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 dbb4e405d..c00b9a71b 100644 --- a/tripleo_ansible/roles/tripleo_hosts_entries/tasks/main.yml +++ b/tripleo_ansible/roles/tripleo_hosts_entries/tasks/main.yml @@ -31,10 +31,6 @@ run_once: true set_fact: tripleo_hosts_entries_block: | - {{ tripleo_hosts_entries_undercloud_hosts_entries | default([]) | join('') }} - - {{ tripleo_hosts_entries_vip_hosts_entries | default([]) | join('') }} - {% for host in groups['overcloud'] -%} {{ hostvars[host][hostvars[host]['hostname_resolve_network'] ~ '_ip'] ~ ' ' ~ host ~ '.' ~ cloud_domain ~ ' ' ~ host }} @@ -50,10 +46,7 @@ {% endif -%} {{ hostvars[host]['ctlplane_ip'] ~ ' ' ~ host ~ '.ctlplane' ~ '.' ~ cloud_domain ~ ' ' ~ host ~ '.ctlplane' }} - - {% endfor -%} - - {{ tripleo_hosts_entries_extra_hosts_entries | default([]) | join('') }} + {% endfor %} tags: - tripleo_hosts_entries @@ -64,6 +57,12 @@ path: "{{ tripleo_hosts_entries_hosts_path }}" # BOF denotes the beginning of the file. insertbefore: BOF - block: "{{ tripleo_hosts_entries_block }}" + block: | + {{ tripleo_hosts_entries_block }} + {% for host in tripleo_hosts_entries_undercloud_hosts_entries | default([]) + + tripleo_hosts_entries_vip_hosts_entries | default([]) + + tripleo_hosts_entries_extra_hosts_entries | default([]) %} + {{ host }} + {% endfor %} tags: - tripleo_hosts_entries