handling stderr

I have a playbook with the following contents

When: is executed first and at this time output is not populated since command has not run yet.

You need to split it in two tasks, one that check and one that create with the result that you don't need the handler.