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

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

What is your actual question?

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