We are working on moving from CentOS to Rocky, changing bits and pieces of our Ansible setup. I ran into a problem yesterday when using a conditional and ansible_os_family.
for our Red Hat based systems and when I ran that against a test Rocky system, it was skipped. Looking into it, the fact that ansible pulled is “ansible_os_family”: “Rocky”.
So my question, should “ansible_os_family” be RedHat instead of Rocky as CentOS is? Is that a bug, or by design?
That’s not intended, no. Your Ansible installation is falling-back to that value since it does not include the patches which lets it know Rocky is a RHEL-like system.
'2.11':
ansible_os_family: RedHat # -> this is correct
'2.10':
ansible_os_family: Rocky # -> this is incorrect
'2.9':
ansible_os_family: Rocky # -> this is incorrect
ansible 2.9 is very old and at the time Rocky Linux was finished there was already a feature freeze in place, that’s why it will not be fixed. To mitigate the issue at least a little bit the ansible 2.9 in EPEL was patched, so that it shows ‘RedHat’.
That means, if you are using ansible 2.9 but not the version from EPEL you might want to change your conditions from
when: ansible_os_family == 'RedHat'
to when: ansible_os_family in ['RedHat', 'Rocky']
P.S.: in my original post I got it wrong for ansible 2.10, 2.10 is also not fixed! I corrected this in the table above.