# How to pass information in a workflow and reuse it in a "summary play" (debug)

**URL:** <https://forum.ansible.com/t/how-to-pass-information-in-a-workflow-and-reuse-it-in-a-summary-play-debug/38024>\
**Category:** AWX Project\
**Created:** [May 23, 2023, 2:38pm UTC](https://forum.ansible.com/t/how-to-pass-information-in-a-workflow-and-reuse-it-in-a-summary-play-debug/38024 "2023-05-23T14:38:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Philipp\_Marti](https://avatars.discourse-cdn.com/v4/letter/p/b38774/32.png) [@Philipp\_Marti](https://forum.ansible.com/u/Philipp_Marti)\
**Post date:** [May 23, 2023, 2:38pm UTC](https://forum.ansible.com/t/how-to-pass-information-in-a-workflow-and-reuse-it-in-a-summary-play-debug/38024/1 "2023-05-23T14:38:58Z")

</div>

Let’s assume I have a hostgroup of 6 hosts and I need to run a playbook (play1) two times in sequence for different hosts in that group because of depenencies between some hosts.

I’d like to gather information within both plays and pass that information further.  
In a last step I’d like to reuse the previously collected information in order to create a summary over all hosts (in both plays 1\_a and 1\_b); here for debugging (later I’d  
like to use that information to create an html report with a Jinja2 templating).

The problem I have is the information in the debug messages are not per host. It seems it stores just the output from one host and reuses it for all others in the  
inventory in the last play (see sample output of the report\_comment variable below → just one of those 6 servers had that exception).

I’m not sure if using the set\_stats module is the best way to reach what I’d like?  
Or would it be better to store the information in temp. files on localhost and read the information in the last play?

Any ideas or suggestions how to reach my goal would be much appreciated!

Workflow Template

> -------------| |-------------| |-------------|  
> play1\_a | —\> | play1\_b | —\> | summary |

> -------------| |-------------| |-------------|

play1\_a:

---

<div class="post-metadata">

**Author:** ![Walter\_Rowe](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/walter_rowe/32/4506_2.png) [@Walter\_Rowe](https://forum.ansible.com/u/Walter_Rowe)\
**Post date:** [May 23, 2023, 7:20pm UTC](https://forum.ansible.com/t/how-to-pass-information-in-a-workflow-and-reuse-it-in-a-summary-play-debug/38024/2 "2023-05-23T19:20:36Z")

</div>

I worked around this by creating a dictionary in set\_stats. The dictionary consists of a key set to hostname and a value set to my per-host data (can be anything including another dictionary). Downstream plays get the dictionary and each host can find its own data using its hostname as the key into that dict.

```auto
- name: Create and Add items to dictionary
  set_stats: 
    data:
      my_dict: "{{ my_dict | default({}) | combine ({ item.key : item.value }) }}"
  with_items:
    - { "key": "{{ inventory_hostname_short }}" , "value": {
          "var_a" : "{{ var_a_val }}",
          "var_b" : "{{ var_b_val }}",
          "var_c" : "{{ var_c_val }}"
        }
      }

```

The downstream playbooks can use my\_dict[inventory\_hostname\_short] to access their specific data.

Walter

---

<div class="post-metadata">

**Author:** ![Philipp\_Marti](https://avatars.discourse-cdn.com/v4/letter/p/b38774/32.png) [@Philipp\_Marti](https://forum.ansible.com/u/Philipp_Marti)\
**Post date:** [May 24, 2023, 2:45pm UTC](https://forum.ansible.com/t/how-to-pass-information-in-a-workflow-and-reuse-it-in-a-summary-play-debug/38024/3 "2023-05-24T14:45:51Z")

</div>

Hi Walter  
Thanks a lot for your input! That seems to work for me as well - you made my day 😉  
Much appreciated!  
Phil
