Conditionals — Ansible Documentation
docs.ansible.com › ansible › latestDec 21, 2021 · ansible_facts [‘os_family’] Basic conditionals with when The simplest conditional statement applies to a single task. Create the task, then add a when statement that applies a test. The when clause is a raw Jinja2 expression without double curly braces (see group_by_module ).
python - Specifying the OS - Ansible - Stack Overflow
https://stackoverflow.com/questions/33762738The normal approach to this is to have an OS family specific task file that is conditionally included by checking the ansible_os_family fact.. So you may have a main.yml task file in your role that looks something like: # Arbitrary task here, not needed but the point is you can have any generic tasks directly in main.yml - name: get the date shell: `date` register: date - include: debian.yml ...