title: Ansible - Conditionally set volume and tls hostname based on inventory file in docker module
body: <p>I'm using Ansible to deploy my containers to production. During development, I'd like to have Ansible deploy all containers on my localhost instead of the production servers. </p>
  
  <p>Production servers run on Ubuntu, localhost is OS X with boot2docker. </p>
  
  <p>I have 2 inventory files, production and localhost. My dir structure looks like this:</p>
  
  <pre><code>.
  |--inventories
  |  |localhost
  |  |production
  |
  |--group_vars
  |  |all
  |  |localhost
  |  |production
  |
  |--roles
  |  |--web
  |     |--tasks
           |main.yml
  |
  |web.yml 
  </code></pre>
  
  <p><em>web.yml</em> just defines the host group and assigns the <code>web</code> role.</p>
  
  <p><em>/roles/web/tasks/main.yml</em> looks like this:</p>
  
  <pre><code>- name: Run web container
    docker:
      name: web
      image: some/image
      state: reloaded
      ...
      tls_hostname: boot2docker
      volumes:
        - "/data/db:/data/db"
      env:
        ...
    tags:
      - ...
  </code></pre>
  
  <p>I need to set <code>tls_hostname</code> conditionally, only if the localhost inventory was used; likewise, I want to set the volume only if the production inventory file was used. </p>
  
  <p>Very new to Ansible - it seems like I'm not approaching this to right way there's an easier way to do this? I want to avoid creating completely separate tasks to deploy locally; I just need a way to define volume and <code>tls_hostname</code> conditionally (and leave it at default setting otherwise)</p>