conditional "when" doesn't work..

Hello,

following doesn’t work:

% nl -ba OS.yml
1 —
2 - hosts: all
3 tasks:
4 - name: print Ubuntu
5 shell: echo Ubuntu
6 when: ansible_os_family == “Ubuntu”
7
8 - name: print Debian
9 shell: echo Debian
10 when: ansible_os_family == “Debian”

Do you have an idea?

Thnx, regards
:slight_smile:

ansible_os_family for Ubuntu is Debian, by design, as it’s in the Debian family.

Similarly, Fedora is a Red Hat derived distribution, as is CentOS.

You should use a different fact.

see “ansible hostname -m setup” for all available facts.