title: Specifying the OS - Ansible
body: <p>I'm a newbie in <code>Ansible</code>, so I wrote a little ansible utility to install some package dependencies for a system I'm writing:</p>
  
  <pre><code>---
  
  - hosts: all
    user: root
    tasks:
        - name: install requirements
          apt: name={{item}} state=latest update_cache=true
          with_items:
              - gcc
              - python-dev
              - python-setuptools
              - python-software-properties
  </code></pre>
  
  <p>The current supported environments are <code>Ubuntu</code>, <code>Red Hat</code> and <code>Mac OS X</code>. The current way this playbook is written it will only work in <code>Ubuntu (Debian)</code>. How can I have that part of the code be executed according to the OS? For <code>Ubuntu</code> it's <code>apt</code>, for <code>Red Hat</code> it's <code>yum</code> and for <code>Mac OS X</code> <code>brew</code>.</p>