# Filtering and executing tasks based upon facts

**URL:** <https://forum.ansible.com/t/filtering-and-executing-tasks-based-upon-facts/30012>\
**Category:** Ansible Project\
**Created:** [March 28, 2019, 4:17pm UTC](https://forum.ansible.com/t/filtering-and-executing-tasks-based-upon-facts/30012 "2019-03-28T16:17:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![computerprosupport](https://avatars.discourse-cdn.com/v4/letter/c/ad7895/32.png) [@computerprosupport](https://forum.ansible.com/u/computerprosupport)\
**Post date:** [March 28, 2019, 4:17pm UTC](https://forum.ansible.com/t/filtering-and-executing-tasks-based-upon-facts/30012/1 "2019-03-28T16:17:02Z")

</div>

I am trying to use conditionals to determine if I run a task, It seems that the when conditional does not work for some tasks. Is there a syntax error here or am i formatting my yaml incorrectly. Any and all examples of working conditionals would be apprecitated.

ansible-\> cat copy-file.yml

---

<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:** [March 28, 2019, 8:11pm UTC](https://forum.ansible.com/t/filtering-and-executing-tasks-based-upon-facts/30012/2 "2019-03-28T20:11:11Z")

</div>

I think you want ‘ansible\_distribution == “CentOS”’. “ansible\_os\_family” should be “RedHat” for both CentOS and RHEL.

–Steve
