Multi OS playbook

Hi,

Is it possible to have multi os , playbook without having factor or ohai on remote nodes ?

I have used $ansible_distribution successfully to detect OS in my playbook , when i try only_if … But i am not able to use the same to have OS specific variables, like using yum or apt based on OS, and select packages for yum or apt based on variables.

You don’t need ohai for $ansible_distribution. That’s alrady provided by facts. If your play optionally disabled facts (by writing gather_facts: no), then you won’t be able to them.

https://github.com/ansible/ansible/blob/devel/examples/playbooks/selective_file_sources.yml

To view all the options you can get from facts, try this command:
ansible -m setup 127.0.0.1 -u -k

output: https://gist.github.com/4689592

Part of the output is $ansible_distribution

OS-specific tasks, e.g. apt vs yum:
http://ansible.cc/docs/playbooks2.html#conditional-execution

OS-specific variables:
http://ansible.cc/docs/playbooks2.html#conditional-imports