# using assert in ansible

**URL:** <https://forum.ansible.com/t/using-assert-in-ansible/31801>\
**Category:** Ansible Project\
**Created:** [December 10, 2019, 3:30pm UTC](https://forum.ansible.com/t/using-assert-in-ansible/31801 "2019-12-10T15:30:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![evnflow](https://avatars.discourse-cdn.com/v4/letter/e/a4c791/32.png) [@evnflow](https://forum.ansible.com/u/evnflow)\
**Post date:** [December 10, 2019, 3:30pm UTC](https://forum.ansible.com/t/using-assert-in-ansible/31801/1 "2019-12-10T15:30:04Z")

</div>

I have a playbook and I am using the following assertion

assert:  
that: ( (disk\_usage|float)/mount.size\_total ) \< disk\_limit|float  
msg: “Disk usage {{ disk\_usage\_ratio\_s }} exceeds {{ disk\_limit\_ratio\_s }}”  
any\_errors\_fatal: true

My question is how do I register the output of **that: ( (disk\_usage|float)/mount.size\_total ) \< disk\_limit|float**

I would like to register the output so I can send email when I do not get the desired result. Any advice would be appreciated.

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [December 10, 2019, 3:36pm UTC](https://forum.ansible.com/t/using-assert-in-ansible/31801/2 "2019-12-10T15:36:27Z")

</div>

> I have a playbook and I am using the following assertion
> 
> assert:  
> that: ( (disk\_usage|float)/mount.size\_total ) \< disk\_limit|float  
> msg: "Disk usage {{ disk\_usage\_ratio\_s }} exceeds {{ disk\_limit\_ratio\_s }}"  
> any\_errors\_fatal: true
> 
> My question is how do I register the output of \*that: ( (disk\_usage|float)/mount.size\_total ) \< disk\_limit|float \*
> 
> I would like to register the output so I can send email when I do not get the desired result. Any advice would be  
> appreciated.

I would run a "set\_fact" task before the "assert" task which captures the output of your expression.

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke

---

<div class="post-metadata">

**Author:** ![evnflow](https://avatars.discourse-cdn.com/v4/letter/e/a4c791/32.png) [@evnflow](https://forum.ansible.com/u/evnflow)\
**Post date:** [December 10, 2019, 7:57pm UTC](https://forum.ansible.com/t/using-assert-in-ansible/31801/3 "2019-12-10T19:57:57Z")

</div>

Thanks for the reply! having issues setting the “set\_fact” the correct way.
