# Help needed to alter my code to achieve when condition in loop in stdout

**URL:** <https://forum.ansible.com/t/help-needed-to-alter-my-code-to-achieve-when-condition-in-loop-in-stdout/35891>\
**Category:** Ansible Project\
**Created:** [October 18, 2021, 2:34pm UTC](https://forum.ansible.com/t/help-needed-to-alter-my-code-to-achieve-when-condition-in-loop-in-stdout/35891 "2021-10-18T14:34:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hareesh\_Vn](https://avatars.discourse-cdn.com/v4/letter/h/f14d63/32.png) [@Hareesh\_Vn](https://forum.ansible.com/u/Hareesh_Vn)\
**Post date:** [October 18, 2021, 2:34pm UTC](https://forum.ansible.com/t/help-needed-to-alter-my-code-to-achieve-when-condition-in-loop-in-stdout/35891/1 "2021-10-18T14:34:09Z")

</div>

Hi Team

I am installing Mongo on n number of nodes. I have written ansible code for it and its working.

When it comes to beatification, like

1. Pass the result of installation to variable (example: result). So this result variable will have output of installation of all nodes.
2. So in case of error, i am passing debug message, "configuration failed on xyz server)

TO achieve this when condition against stdout format , i am failing

Please help

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [October 18, 2021, 2:38pm UTC](https://forum.ansible.com/t/help-needed-to-alter-my-code-to-achieve-when-condition-in-loop-in-stdout/35891/2 "2021-10-18T14:38:15Z")

</div>

What is your actual question?

---

<div class="post-metadata">

**Author:** ![Hareesh\_Vn](https://avatars.discourse-cdn.com/v4/letter/h/f14d63/32.png) [@Hareesh\_Vn](https://forum.ansible.com/u/Hareesh_Vn)\
**Post date:** [October 18, 2021, 3:04pm UTC](https://forum.ansible.com/t/help-needed-to-alter-my-code-to-achieve-when-condition-in-loop-in-stdout/35891/3 "2021-10-18T15:04:38Z")

</div>

my code with reference to passing when condition against stdout is not working as expected. May be we can chat or have internet call?
