title: Ansible - Default/Explicit Tags
body: <p>I've got a playbook that includes and tags various roles:</p>
  
  <pre><code>- name:  base
    hosts: "{{ host | default('localhost') }}"
  
  roles: 
  
    - { role: apt,              tags: [ 'base', 'apt', 'ubuntu']}
    - { role: homebrew,         tags: [ 'base', 'homebrew', osx' ]}
    - { role: base16,           tags: [ 'base', 'base16', 'osx' ]}
    - { role: nodejs,           tags: [ 'base', 'nodejs' ]}
    - { role: tmux,             tags: [ 'base', 'tmux' ]}
    - { role: vim,              tags: [ 'base', 'vim' ]}
    - { role: virtualenv,       tags: [ 'base',  virtualenv', 'python' ]}
    - { role: homebrew_cask,    tags: [ 'desktop', 'homebrew_cask', osx' ]}
    - { role: gnome_terminator, tags: [ 'desktop', 'gnome_terminator', ubuntu' ]}
  </code></pre>
  
  <p>Most of the tasks are using when clauses to determine which OS they should run on, for example:</p>
  
  <pre><code>- name: install base packages
    when: ansible_distribution == 'MacOSX'
    sudo: no
    homebrew:
      name: "{{ item.name }}"
      state: latest
      install_options: "{{ item.install_options|default() }}"
    with_items: homebrew_packages
  </code></pre>
  
  <p>If I run <code>ansible-playbook base.yml</code> without specifying any tags, all the tasks run. If I specify a tag, for example <code>ansible-playbook base.yml --tags='base'</code>, only the roles tagged with <code>base run</code>.</p>
  
  <p>By default (if no tags are specified), I'd only like to run the roles tagged with <code>'base'</code>, and <em>not</em> the roles tagged with <code>'desktop'</code>.</p>
  
  <p>It would also be really nice to set a default 'os' tag, based on the current operating system, to avoid including all the tasks for the ubuntu when I'm running the playbook on OSX (and vice-versa).</p>
  
  <p>Any ideas if this is possible, and how I might do it?</p>