title: Ansible - variable for a specific inventory
body: <p>I have a multi environment &amp; multi inventories setup within ansible (2.7.9).
  With one of the inventories, I am wanting to set a global variable to be inherited by all the hosts within the inventory. For this purpose I added the variable into that specific inventory (<code>inventory/production/prodinv</code>):</p>
  <pre><code>[all:vars]
  myvar=&quot;True&quot;
  </code></pre>
  <p>And it works fine if I ran ansible against that specific inventory (<code>inventory/production/prodinv</code>). However, if I run ansible against the inventory directory (eg <code>inventory/production</code>) , I noticed that the variable is inherited on all the hosts across all the inventories - which isn't ideal because I only want the hosts within <code>firstenv</code> inventory to have the var defined.</p>
  <p>Currently group_vars and host_vars are a symlink (for all the inventories) against a &quot;shared&quot; root group_vars and host_vars.</p>
  <p>To add more clarity to my question, below is the structure of my ansible:</p>
  <pre><code>.
  ├── ansible.cfg
  ├── playbooks/
  ├── roles/
  ├── inventory/
  │   │
  │   ├── group_vars/
  |   |
  |   ├── host_vars/
  |   |
  │   ├── tnd/
  │   │   ├── group_vars/ -&gt; ../group_vars
  │   |   ├── host vars/  -&gt; ../host_vars
  │   │   └── devinv      
  │   │
  │   ├── production/
  │   │   ├── group_vars/ -&gt; ../group_vars
  │   |   ├── host vars/  -&gt; ../host_vars
  │   │   └── prodinv   
  │
  └── . . 
  
  </code></pre>
  <p>I'm not sure how / where to define this var that should apply to all hosts/groups within a particular inventory, without running into the same issue. Ideas?</p>
  <p>Thanks,
  J</p>