How to skip and move on to the next task if a condition is met?

Hi all,

Newbie here - I’m writing a playbook that I’m running a shell script and if the output is X then I want to skip the task and move on to the next task.

How do I do this?

Thanks

You use “register: myVariable” on the shell task, then “when: myVariable.stdout == XY” on the next task.

https://www.mydailytutorials.com/ansible-register-variables/

//magnus