# assert vs fail

**URL:** <https://forum.ansible.com/t/assert-vs-fail/30771>\
**Category:** Ansible Project\
**Created:** [July 12, 2019, 3:12pm UTC](https://forum.ansible.com/t/assert-vs-fail/30771 "2019-07-12T15:12:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![S\_C\_Rigler](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@S\_C\_Rigler](https://forum.ansible.com/u/S_C_Rigler)\
**Post date:** [July 12, 2019, 3:12pm UTC](https://forum.ansible.com/t/assert-vs-fail/30771/1 "2019-07-12T15:12:24Z")

</div>

Is there any advantage to using the assert module vs the fail module to bail out of a play if an expected condition isn’t met?

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [July 12, 2019, 3:21pm UTC](https://forum.ansible.com/t/assert-vs-fail/30771/2 "2019-07-12T15:21:42Z")

</div>

The outcome is the same, but they work opposite way

- fail:  
&nbsp;&nbsp;&nbsp;&nbsp;msg="Hello"  
&nbsp;&nbsp;when: myvar == True

- assert:  
&nbsp;&nbsp;&nbsp;&nbsp;that: myvar == True

If myvar is True the fail will stop the play and the assert will continue the play.  
And if myvar is False the opposite will happen.

---

<div class="post-metadata">

**Author:** ![hugonz](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/hugonz/32/503_2.png) [@hugonz](https://forum.ansible.com/u/hugonz)\
**Post date:** [July 12, 2019, 4:10pm UTC](https://forum.ansible.com/t/assert-vs-fail/30771/3 "2019-07-12T16:10:39Z")

</div>

Hi,
