# skip a play in a playbook?

**URL:** <https://forum.ansible.com/t/skip-a-play-in-a-playbook/14648>\
**Category:** Ansible Project\
**Created:** [February 25, 2014, 12:18pm UTC](https://forum.ansible.com/t/skip-a-play-in-a-playbook/14648 "2014-02-25T12:18:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeremy\_Schulman](https://avatars.discourse-cdn.com/v4/letter/j/d26b3c/32.png) [@Jeremy\_Schulman](https://forum.ansible.com/u/Jeremy_Schulman)\
**Post date:** [February 25, 2014, 12:18pm UTC](https://forum.ansible.com/t/skip-a-play-in-a-playbook/14648/1 "2014-02-25T12:18:41Z")

</div>

lets say i have a playbook with three plays. i would like to skip the middle play if some condition is met. is this possible without having to add a 'when' condition to each task in the middle play?

thank you1

---

<div class="post-metadata">

**Author:** ![tannerjc](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/tannerjc/32/985_2.png) [@tannerjc](https://forum.ansible.com/u/tannerjc)\
**Post date:** [February 25, 2014, 12:39pm UTC](https://forum.ansible.com/t/skip-a-play-in-a-playbook/14648/2 "2014-02-25T12:39:42Z")

</div>

Roles can be run conditionally, so you might want to look at transitioning the “middle” play to a role if you do not want to mark every task with a when: statement.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [February 25, 2014, 1:00pm UTC](https://forum.ansible.com/t/skip-a-play-in-a-playbook/14648/3 "2014-02-25T13:00:22Z")

</div>

group\_by is a really good module to use here, actually.

The benefit is that you don’t see the “skipped” for every task in the role.

[http://docs.ansible.com/group\_by\_module.html](http://docs.ansible.com/group_by_module.html)

Run group\_by in one task in play #1 and have play2 target the new temporary group.

---

<div class="post-metadata">

**Author:** ![Jeremy\_Schulman](https://avatars.discourse-cdn.com/v4/letter/j/d26b3c/32.png) [@Jeremy\_Schulman](https://forum.ansible.com/u/Jeremy_Schulman)\
**Post date:** [February 25, 2014, 3:08pm UTC](https://forum.ansible.com/t/skip-a-play-in-a-playbook/14648/4 "2014-02-25T15:08:07Z")

</div>

thank you, i will try those approaches. much appreciated!
