I'm new to Ansible. I created a playbook that uses PowerShell to reset your password of your admin account. The script has a check that only resets the password IF the account is enabled. When the account is disabled, it spits out a write-host
saying they should create a ticket.
This all works fine , however, the job ends with a green status. Technically, this is correct cause the whole playbook ran correctly. But for the end user, he/she will think that the password was reset. (Yes the message clearly state it didn't, but i know how users are, they don't read and only look at colors).
So my question is with win_shell
how can i change the color of the job from green to orange or red?
I know it is possible with ansible.windows.win_powershell
but we don't have that module. So it has to be with win_shell
.
Hope this is an easy ask. Thank you kindly.
Edit, solution:
Thanks to Hendrik Pingel below. I made sure to only include the phrase below after all my needed changes are done. So unless the script spits this out, something went wrong and i can safely change color to red.
- name: Change flag to red if there was no success in the message output.
debug:
msg: "{{lookupResult.stdout_lines}}"
failed_when: '"Password reset was a success" not in lookupResult.stdout'
S.