# Multi OS playbook

**URL:** <https://forum.ansible.com/t/multi-os-playbook/12277>\
**Category:** Ansible Project\
**Created:** [February 1, 2013, 2:06am UTC](https://forum.ansible.com/t/multi-os-playbook/12277 "2013-02-01T02:06:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kavin](https://avatars.discourse-cdn.com/v4/letter/k/ba8739/32.png) [@Kavin](https://forum.ansible.com/u/Kavin)\
**Post date:** [February 1, 2013, 2:06am UTC](https://forum.ansible.com/t/multi-os-playbook/12277/1 "2013-02-01T02:06:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![John\_Wong](https://avatars.discourse-cdn.com/v4/letter/j/6f9a4e/32.png) [@John\_Wong](https://forum.ansible.com/u/John_Wong)\
**Post date:** [February 1, 2013, 6:01am UTC](https://forum.ansible.com/t/multi-os-playbook/12277/2 "2013-02-01T06:01:42Z")

</div>

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](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](https://gist.github.com/4689592)

Part of the output is $ansible\_distribution

---

<div class="post-metadata">

**Author:** ![Ahmad\_Khayyat](https://avatars.discourse-cdn.com/v4/letter/a/858c86/32.png) [@Ahmad\_Khayyat](https://forum.ansible.com/u/Ahmad_Khayyat)\
**Post date:** [February 1, 2013, 7:10am UTC](https://forum.ansible.com/t/multi-os-playbook/12277/3 "2013-02-01T07:10:49Z")

</div>

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

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