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

**URL:** <https://forum.ansible.com/t/how-to-skip-and-move-on-to-the-next-task-if-a-condition-is-met/33317>\
**Category:** Ansible Developer\
**Created:** [July 3, 2020, 11:51am UTC](https://forum.ansible.com/t/how-to-skip-and-move-on-to-the-next-task-if-a-condition-is-met/33317 "2020-07-03T11:51:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amir\_Alavi](https://avatars.discourse-cdn.com/v4/letter/a/dc4da7/32.png) [@Amir\_Alavi](https://forum.ansible.com/u/Amir_Alavi)\
**Post date:** [July 3, 2020, 11:51am UTC](https://forum.ansible.com/t/how-to-skip-and-move-on-to-the-next-task-if-a-condition-is-met/33317/1 "2020-07-03T11:51:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Magnus\_Lubeck](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/magnus_lubeck/32/3905_2.png) [@Magnus\_Lubeck](https://forum.ansible.com/u/Magnus_Lubeck)\
**Post date:** [July 3, 2020, 12:31pm UTC](https://forum.ansible.com/t/how-to-skip-and-move-on-to-the-next-task-if-a-condition-is-met/33317/2 "2020-07-03T12:31:04Z")

</div>

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

[https://www.mydailytutorials.com/ansible-register-variables/](https://www.mydailytutorials.com/ansible-register-variables/)

//magnus
