Ansible supports the conditional execution of a task based on the run-time evaluation of variable, fact, or previous task result.
- yum: name: httpd state: latest when: ansible_os_family == "RedHat"