Sometimes in an Ansible playbook, you'll want to condition running a task on whether or not the distribution is CentOS, RHEL, etc, or if it's something else. A very common example is when a package is named one thing on CentOS and something else on Debian.
I see a lot of Ansible playbooks (and have written a few myself) that will handle this by adding a "when:" to the task like this:
when: ansible_distribution == 'CentOS' or ansible_distribution == 'RedHat'
Is there a reason that that's so common instead of checking for os_family? Why do I not see this more often?:
when: ansible_os_family == 'RedHat'
Besides being more direct and concise, that also allows for other EL Linuxes like Scientific Linux and Rocky Linux without having to continually add to a list of all the possible EL derivatives. Is there something I'm missing?
ansible_facts.os_family
meets your needs, use it. If it doesn't, don't.