In Ansible, I need to run some roles only if the host is a WSL host.
How to detect that? I am looking for a form of:
- name: "Run only in WSL"
when: # what to put here?
# task definition
What to put in the when section? I am looking for a way to detect that automatically, NOT to configure a variable on my host in the inventory.
Just gather Ansible facts. There is no need for
command,shell,registerand parsestdoutat all. From a minimal example playbookthe output result will already contain the requested information
or
or
It also contains the
ansible_facts.kernelversionsWith this information Conditionals based on
ansible_factsis trivial. Like in