# Include tasks based on OS distribution

**URL:** <https://forum.ansible.com/t/include-tasks-based-on-os-distribution/30768>\
**Category:** Ansible Project\
**Created:** [July 12, 2019, 10:12am UTC](https://forum.ansible.com/t/include-tasks-based-on-os-distribution/30768 "2019-07-12T10:12:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bruno\_Cochofel](https://avatars.discourse-cdn.com/v4/letter/b/4da419/32.png) [@Bruno\_Cochofel](https://forum.ansible.com/u/Bruno_Cochofel)\
**Post date:** [July 12, 2019, 10:12am UTC](https://forum.ansible.com/t/include-tasks-based-on-os-distribution/30768/1 "2019-07-12T10:12:20Z")

</div>

Hi,

I have some roles that are specific for some OS family and I’m using the include keyword to include a file when ansible\_os\_family matches what I want.  
The problem with this approach is that when is not the family I want it skips but at the end the user that runs this can think that everything was done.

I want to know what’s the best approach for this, thinking that I also need to tell the user (even fail the task in question) based on the OS being different that what it should be.

Thanks,  
Bruno

---

<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, 2:54pm UTC](https://forum.ansible.com/t/include-tasks-based-on-os-distribution/30768/2 "2019-07-12T14:54:21Z")

</div>

If you want to fail the assert module is a good candidate  
[https://docs.ansible.com/ansible/latest/modules/assert\_module.html](https://docs.ansible.com/ansible/latest/modules/assert_module.html)

---

<div class="post-metadata">

**Author:** ![Bruno\_Cochofel](https://avatars.discourse-cdn.com/v4/letter/b/4da419/32.png) [@Bruno\_Cochofel](https://forum.ansible.com/u/Bruno_Cochofel)\
**Post date:** [July 13, 2019, 10:08am UTC](https://forum.ansible.com/t/include-tasks-based-on-os-distribution/30768/3 "2019-07-13T10:08:18Z")

</div>

Hi Kai,

Thanks for the answer, gonna give it a try.

Thanks,  
Bruno
