<p dir="auto">paramiko has a helper class SSHConfig() which can read in ~/.ssh/config.<br>
This might be helpful if special configuration is done to hop to a second<br>
host, hardcode ports or other special configuration, so that the config does<br>
not need to get duplicated for ansible.</p>
<p dir="auto">best regards,</p>
<p dir="auto">Florian La Roche</p>
<h5 dir="auto">Issue Type:</h5>
<p dir="auto">Bug Report</p>
<h5 dir="auto">Ansible Version:</h5>
<p dir="auto">Introduced in v2.0.0-0.3.beta1, bug not present in v2.0.0-0.2.alpha2.</p>
<h5 dir="auto">Ansible Configuration:</h5>
<p dir="auto">in ansible.cfg, use a directory as inventory</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="inventory = hosts/"><pre class="notranslate"><code class="notranslate">inventory = hosts/
</code></pre></div>
<p dir="auto">Debian Jessie.</p>
<h5 dir="auto">Summary:</h5>
<p dir="auto">I've configured 2 host files in hosts/ directory: hosts/a and hosts/b. Both contains groups, and one host is configured into 2 groups in 2 host files, with one host var for each.</p>
<p dir="auto">hosts/a :</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[groupA]
test datacenter=PA3"><pre class="notranslate"><code class="notranslate">[groupA]
test datacenter=PA3
</code></pre></div>
<p dir="auto">hosts/b :</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[groupB]
test bay=202"><pre class="notranslate"><code class="notranslate">[groupB]
test bay=202
</code></pre></div>
<p dir="auto">playbook test.yml:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="- name: TEST
  hosts: test
  gather_facts: yes

  tasks:
  - name: debug
    debug: var=hostvars[inventory_hostname].datacenter
    ignore_errors: True

  - name: debug
    debug: var=hostvars[inventory_hostname].bay
    ignore_errors: True"><pre class="notranslate"><code class="notranslate">- name: TEST
  hosts: test
  gather_facts: yes

  tasks:
  - name: debug
    debug: var=hostvars[inventory_hostname].datacenter
    ignore_errors: True

  - name: debug
    debug: var=hostvars[inventory_hostname].bay
    ignore_errors: True
</code></pre></div>
<p dir="auto">With Ansible v1.9 or previous to v2.0.0-0.3.beta1, both host vars are accessible, but since this version only one random host vars (datacenter or bay) is accessible.</p>
<p dir="auto">Tried with both hash_behaviour merge and replace.</p>
<h5 dir="auto">Expected Results:</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="PLAY [TEST] ********************************************************************

TASK [setup] *******************************************************************
ok: [test]

TASK [debug] *******************************************************************
ok: [test] =&gt; {
    &quot;changed&quot;: false, 
    &quot;hostvars[inventory_hostname].datacenter&quot;: &quot;PA3&quot;
}

TASK [debug] *******************************************************************
ok: [test] =&gt; {
    &quot;changed&quot;: false, 
    &quot;hostvars[inventory_hostname].bay&quot;: &quot;202&quot;
}

PLAY RECAP *********************************************************************
test               : ok=3    changed=0    unreachable=0    failed=0   
"><pre class="notranslate"><code class="notranslate">PLAY [TEST] ********************************************************************

TASK [setup] *******************************************************************
ok: [test]

TASK [debug] *******************************************************************
ok: [test] =&gt; {
    "changed": false, 
    "hostvars[inventory_hostname].datacenter": "PA3"
}

TASK [debug] *******************************************************************
ok: [test] =&gt; {
    "changed": false, 
    "hostvars[inventory_hostname].bay": "202"
}

PLAY RECAP *********************************************************************
test               : ok=3    changed=0    unreachable=0    failed=0   

</code></pre></div>
<h5 dir="auto">Actual Results:</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="PLAY [TEST] ********************************************************************

TASK [setup] *******************************************************************
ok: [test]

TASK [debug] *******************************************************************
ok: [test] =&gt; {
    &quot;changed&quot;: false, 
    &quot;hostvars[inventory_hostname].datacenter&quot;: &quot;PA3&quot;
}

TASK [debug] *******************************************************************
fatal: [test]: FAILED! =&gt; {&quot;failed&quot;: true, &quot;msg&quot;: &quot;ERROR! 'dict object' has no attribute 'bay'&quot;}
...ignoring

PLAY RECAP *********************************************************************
test               : ok=3    changed=0    unreachable=0    failed=0   
"><pre class="notranslate"><code class="notranslate">PLAY [TEST] ********************************************************************

TASK [setup] *******************************************************************
ok: [test]

TASK [debug] *******************************************************************
ok: [test] =&gt; {
    "changed": false, 
    "hostvars[inventory_hostname].datacenter": "PA3"
}

TASK [debug] *******************************************************************
fatal: [test]: FAILED! =&gt; {"failed": true, "msg": "ERROR! 'dict object' has no attribute 'bay'"}
...ignoring

PLAY RECAP *********************************************************************
test               : ok=3    changed=0    unreachable=0    failed=0   

</code></pre></div>