From 6db0ac0856b369ee13dc17db7be7ef8c124a8b4b Mon Sep 17 00:00:00 2001 From: Rabi Mishra Date: Thu, 2 Apr 2020 12:51:21 +0530 Subject: [PATCH] Include {{step}} when setting facts We don't set the fact specific to a step and it seems to run those puppet tasks for subsequent steps too. Change-Id: Ic276ea6f34dd638ad66505aa77bddff0e4071ad4 Closes-Bug #1870291 --- common/deploy-steps-tasks.yaml | 6 +++--- common/host-container-puppet-tasks.yaml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/deploy-steps-tasks.yaml b/common/deploy-steps-tasks.yaml index ed5319861e..eb01a35e8b 100644 --- a/common/deploy-steps-tasks.yaml +++ b/common/deploy-steps-tasks.yaml @@ -162,8 +162,8 @@ - name: Calculate container_puppet_tasks for {{ansible_hostname | lower}} step {{step}} set_fact: - host_container_puppet_tasks: "{{host_container_puppet_tasks|default([]) + [item]}}" - loop: "{{container_puppet_tasks.get('step_' + step, [])}}" + "{{'host_container_puppet_tasks_' ~ step}}": "{{lookup('vars', 'host_container_puppet_tasks_' ~ step, default=[]) | union([item])}}" + loop: "{{container_puppet_tasks.get('step_' ~ step, [])}}" when: (groups[item.service_name] | default ([]) | map('extract', hostvars, 'inventory_hostname') | sort | first | lower) == ansible_hostname | lower vars: container_puppet_tasks: "{{ lookup('file', tripleo_role_name + '/container_puppet_tasks.yaml', errors='ignore') | default({}, True) | from_yaml }}" @@ -172,6 +172,6 @@ - name: Include container-puppet tasks for step {{step}} include_tasks: host-container-puppet-tasks.yaml - when: host_container_puppet_tasks is defined + when: ('host_container_puppet_tasks_' ~ step) is defined tags: - container_config_tasks diff --git a/common/host-container-puppet-tasks.yaml b/common/host-container-puppet-tasks.yaml index 18fdb55db0..e2cbb67e05 100644 --- a/common/host-container-puppet-tasks.yaml +++ b/common/host-container-puppet-tasks.yaml @@ -1,7 +1,7 @@ - name: Write container-puppet-tasks json file for {{ansible_hostname | lower}} step {{step}} no_log: True copy: - content: "{{host_container_puppet_tasks|to_nice_json}}" + content: "{{lookup ('vars', 'host_container_puppet_tasks_' ~ step, default=[]) | to_nice_json}}" dest: "/var/lib/container-puppet/container-puppet-tasks{{step}}.json" force: yes mode: '0600'