<h5 dir="auto">ISSUE TYPE</h5>
<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">ANSIBLE VERSION</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.1.0.0"><pre class="notranslate"><code class="notranslate">ansible 2.1.0.0
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[defaults]
hostfile = hosts
roles_path = ./roles:./external_roles
transport = ssh
hash_behaviour = merge
retry_files_enabled = False

[ssh_connection]
ssh_args = -o ForwardAgent=yes
scp_if_ssh = True
control_path = ~/.ssh/mux-%%r@%%h:%%p"><pre class="notranslate"><code class="notranslate">[defaults]
hostfile = hosts
roles_path = ./roles:./external_roles
transport = ssh
hash_behaviour = merge
retry_files_enabled = False

[ssh_connection]
ssh_args = -o ForwardAgent=yes
scp_if_ssh = True
control_path = ~/.ssh/mux-%%r@%%h:%%p
</code></pre></div>
<h5 dir="auto">OS / ENVIRONMENT</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="CentOS Linux release 7.2.1511"><pre class="notranslate"><code class="notranslate">CentOS Linux release 7.2.1511
</code></pre></div>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">While running long provisioning playbooks on localhost (<code class="notranslate">-c local</code>, not tested on remote) with this version of ansible it hangs forever in different places (usually hags on <code class="notranslate">stat</code>, <code class="notranslate">template</code> <code class="notranslate">file link|absent</code> modules, although there are also other modules).</p>
<p dir="auto">when looking into that machine I got strange errors:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ABRT has detected 2 problem(s). For more info run: abrt-cli list --since 1469104014`

# abrt-cli list
id e89d19d057aae4b747282a38f0dcfa4cecbf0ccf
reason:         systemd-logind killed by SIGABRT
time:           Thu Jul 21 12:30:05 2016
cmdline:        /usr/lib/systemd/systemd-logind
package:        systemd-208-11.el7_0.6
uid:            0 (root)
count:          1
Directory:      /var/spool/abrt/ccpp-2016-07-21-12:30:05-608

id 6c1edc19fab7dec6dc2a3873dcba243dc6d4be12
reason:         systemd-journald killed by SIGABRT
time:           Thu Jul 21 12:30:05 2016
cmdline:        /usr/lib/systemd/systemd-journald
package:        systemd-208-11.el7_0.6
uid:            0 (root)
count:          1
Directory:      /var/spool/abrt/ccpp-2016-07-21-12:30:05-355"><pre class="notranslate"><code class="notranslate">ABRT has detected 2 problem(s). For more info run: abrt-cli list --since 1469104014`

# abrt-cli list
id e89d19d057aae4b747282a38f0dcfa4cecbf0ccf
reason:         systemd-logind killed by SIGABRT
time:           Thu Jul 21 12:30:05 2016
cmdline:        /usr/lib/systemd/systemd-logind
package:        systemd-208-11.el7_0.6
uid:            0 (root)
count:          1
Directory:      /var/spool/abrt/ccpp-2016-07-21-12:30:05-608

id 6c1edc19fab7dec6dc2a3873dcba243dc6d4be12
reason:         systemd-journald killed by SIGABRT
time:           Thu Jul 21 12:30:05 2016
cmdline:        /usr/lib/systemd/systemd-journald
package:        systemd-208-11.el7_0.6
uid:            0 (root)
count:          1
Directory:      /var/spool/abrt/ccpp-2016-07-21-12:30:05-355
</code></pre></div>
<p dir="auto">thsese are in <code class="notranslate">systemctl</code></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;E2&gt;&lt;97&gt;&lt;8F&gt; kdump.service                                    loaded failed failed    Crash recovery kernel arming
&lt;E2&gt;&lt;97&gt;&lt;8F&gt; rightimage.service                               loaded failed failed    LSB: RightLink agent updater
&lt;E2&gt;&lt;97&gt;&lt;8F&gt; rightlink.service                                loaded failed failed    LSB: RightLink agent
&lt;E2&gt;&lt;97&gt;&lt;8F&gt; rightscale.service                               loaded failed failed    LSB: RightScale startup"><pre class="notranslate"><code class="notranslate">&lt;E2&gt;&lt;97&gt;&lt;8F&gt; kdump.service                                    loaded failed failed    Crash recovery kernel arming
&lt;E2&gt;&lt;97&gt;&lt;8F&gt; rightimage.service                               loaded failed failed    LSB: RightLink agent updater
&lt;E2&gt;&lt;97&gt;&lt;8F&gt; rightlink.service                                loaded failed failed    LSB: RightLink agent
&lt;E2&gt;&lt;97&gt;&lt;8F&gt; rightscale.service                               loaded failed failed    LSB: RightScale startup
</code></pre></div>
<p dir="auto">a part of <code class="notranslate">dmesg</code>:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[  893.387473] ansible-playboo[5172]: segfault at 4e40bc000095 ip 00007f7ec189c258 sp 00007f7eb705c990 error 4 in libpython2.7.so.1.0[7f7ec178d000+178000]
[  893.408028] abrt-hook-ccpp[5173]: segfault at 0 ip 00007f39920e753b sp 00007fffb1f06b30 error 4 in libreport.so.0.0.1[7f39920d9000+25000]
[  893.414979] Process 5173(abrt-hook-ccpp) has RLIMIT_CORE set to 1
[  893.418125] Aborting core"><pre class="notranslate"><code class="notranslate">[  893.387473] ansible-playboo[5172]: segfault at 4e40bc000095 ip 00007f7ec189c258 sp 00007f7eb705c990 error 4 in libpython2.7.so.1.0[7f7ec178d000+178000]
[  893.408028] abrt-hook-ccpp[5173]: segfault at 0 ip 00007f39920e753b sp 00007fffb1f06b30 error 4 in libreport.so.0.0.1[7f39920d9000+25000]
[  893.414979] Process 5173(abrt-hook-ccpp) has RLIMIT_CORE set to 1
[  893.418125] Aborting core
</code></pre></div>
<h5 dir="auto">ISSUE TYPE</h5>
<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>
<p dir="auto">Default Variable management</p>
<h5 dir="auto">ANSIBLE VERSION</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.4.0 (fix-aos-login-port 395d4d4c5b) last updated 2017/05/09 08:59:20 (GMT -700)
  config file = /Users/damien/projects/cloudlabs-topologies/two-tier-arista-l3/ansible.cfg
  configured module search path = [u'/Users/damien/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/damien/projects/ansible/lib/ansible
  executable location = /Users/damien/projects/ansible/bin/ansible
  python version = 2.7.10 (default, Feb  6 2017, 23:53:20) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)]"><pre class="notranslate"><code class="notranslate">ansible 2.4.0 (fix-aos-login-port 395d4d4c5b) last updated 2017/05/09 08:59:20 (GMT -700)
  config file = /Users/damien/projects/cloudlabs-topologies/two-tier-arista-l3/ansible.cfg
  configured module search path = [u'/Users/damien/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/damien/projects/ansible/lib/ansible
  executable location = /Users/damien/projects/ansible/bin/ansible
  python version = 2.7.10 (default, Feb  6 2017, 23:53:20) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)]
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=""><pre class="notranslate"><code class="notranslate">
</code></pre></div>
<h5 dir="auto">OS / ENVIRONMENT</h5>
<p dir="auto">Mac OS 10.12.4</p>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">When using multiple inventory files, saved in the directory <code class="notranslate">inventory/</code>, variables stored in <code class="notranslate">host_vars/&lt;inventory_hostname&gt;/xxx.yaml</code> are not loaded.</p>
<p dir="auto">Assuming we have 4 devices, defined in 2 inventories files:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="project/
   inventory/
       inv1 
          host_ccc id=11
          host_ddd id=12
       inv2
          host_aaa id=1
          host_bbb id=2
   host_vars/
       host_aaa/
           fqdn.yaml  `myvar: this is my var` 
       host_bbb.yaml  `myvar: this is my var` "><pre class="notranslate"><code class="notranslate">project/
   inventory/
       inv1 
          host_ccc id=11
          host_ddd id=12
       inv2
          host_aaa id=1
          host_bbb id=2
   host_vars/
       host_aaa/
           fqdn.yaml  `myvar: this is my var` 
       host_bbb.yaml  `myvar: this is my var` 
</code></pre></div>
<p dir="auto">When I'm running a playbook just on 1 device <code class="notranslate">host_ccc</code> (using limit)  the variable from <code class="notranslate">host_aaa</code> &gt; hostvars['host_aaa'].myvar` is undefined</p>
<p dir="auto">if I merge my inventories files (inv1 and inv2) into a single file, the same variable  <code class="notranslate">hostvars['host_aaa'].myvar</code> exist for host_ccc</p>
<p dir="auto">I clearly have a different behavior with 1 or 2 inventory files</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>
<ul dir="auto">
<li>Create a <code class="notranslate">host_vars</code> directory and create some variable file for 3 hosts</li>
<li>Create a inventory directory and create 2 inventories files, with 2 hosts each</li>
<li>Create another inventory with the same content as both previous inventory files combined</li>
<li>Create a playbook to show variables defined inside host_vars for each host</li>
</ul>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="├── host_vars
│   ├── host_aaa
│   │   └── var.yaml
│   ├── host_bbb.yaml
│   └── host_ccc.yaml
├── inventory
│   ├── inv1
│   └── inv2
├── inventory.ini
└── pb.show_var.yaml"><pre class="notranslate"><code class="notranslate">├── host_vars
│   ├── host_aaa
│   │   └── var.yaml
│   ├── host_bbb.yaml
│   └── host_ccc.yaml
├── inventory
│   ├── inv1
│   └── inv2
├── inventory.ini
└── pb.show_var.yaml
</code></pre></div>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="# pb.show_var.yaml
- name: Print Variables
  hosts: all
  gather_facts: no
  connection: local
  tasks:
    - name: Variables for dev_aaa
      debug: var=hostvars['host_aaa'].myvar

    - name: Variables for dev_bbb
      debug: var=hostvars['host_bbb'].myvar

    - name: Variables for dev_ccc (self)
      debug: var=myvar"><pre class="notranslate"><span class="pl-c"><span class="pl-c">#</span> pb.show_var.yaml</span>
- <span class="pl-ent">name</span>: <span class="pl-s">Print Variables</span>
  <span class="pl-ent">hosts</span>: <span class="pl-s">all</span>
  <span class="pl-ent">gather_facts</span>: <span class="pl-s">no</span>
  <span class="pl-ent">connection</span>: <span class="pl-s">local</span>
  <span class="pl-ent">tasks</span>:
    - <span class="pl-ent">name</span>: <span class="pl-s">Variables for dev_aaa</span>
      <span class="pl-ent">debug</span>: <span class="pl-s">var=hostvars['host_aaa'].myvar</span>

    - <span class="pl-ent">name</span>: <span class="pl-s">Variables for dev_bbb</span>
      <span class="pl-ent">debug</span>: <span class="pl-s">var=hostvars['host_bbb'].myvar</span>

    - <span class="pl-ent">name</span>: <span class="pl-s">Variables for dev_ccc (self)</span>
      <span class="pl-ent">debug</span>: <span class="pl-s">var=myvar</span></pre></div>
<div class="highlight highlight-source-ini notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="# Inventory
host_aaa id=1
host_bbb id=2
host_ccc id=11
host_ddd id=12"><pre class="notranslate"><span class="pl-c"><span class="pl-c">#</span> Inventory</span>
host_aaa <span class="pl-k">id</span>=1
host_bbb <span class="pl-k">id</span>=2
host_ccc <span class="pl-k">id</span>=11
host_ddd <span class="pl-k">id</span>=12</pre></div>
<h5 dir="auto">EXPECTED RESULTS</h5>
<p dir="auto">Variables from <code class="notranslate">host_aaa</code> and <code class="notranslate">host_bbb</code> should be defined <code class="notranslate">host_ccc</code> when using multiple inventory files</p>
<h5 dir="auto">ACTUAL RESULTS</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="(ansible-dev) ➜  ansible-bug-inventory-01 git:(master) ansible-playbook -i inventory pb.show_var.yaml --limit=host_ccc

PLAY [Print Variables] **********************************************************************************************

TASK [Variables for dev_aaa] **********************************************************************************************
ok: [host_ccc] =&gt; {
    &quot;hostvars['host_aaa'].myvar&quot;: &quot;VARIABLE IS NOT DEFINED!&quot; &lt;&lt;&lt;&lt;&lt;
}

TASK [Variables for dev_bbb] **********************************************************************************************
ok: [host_ccc] =&gt; {
    &quot;hostvars['host_bbb'].myvar&quot;: &quot;VARIABLE IS NOT DEFINED!&quot; &lt;&lt;&lt;&lt;&lt;&lt;
}

TASK [Variables for dev_ccc (self)] **********************************************************************************************
ok: [host_ccc] =&gt; {
    &quot;myvar&quot;: &quot;this is my var&quot;
}

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

(ansible-dev) ➜  ansible-bug-inventory-01 ansible-playbook -i inventory.ini pb.show_var.yaml --limit=host_ccc

PLAY [Print Variables] *********************************************************************************************

TASK [Variables for dev_aaa] **********************************************************************************************
ok: [host_ccc] =&gt; {
    &quot;hostvars['host_aaa'].myvar&quot;: &quot;this is my var&quot;
}

TASK [Variables for dev_bbb] **********************************************************************************************
ok: [host_ccc] =&gt; {
    &quot;hostvars['host_bbb'].myvar&quot;: &quot;this is my var&quot;
}

TASK [Variables for dev_ccc (self)] **********************************************************************************************
ok: [host_ccc] =&gt; {
    &quot;myvar&quot;: &quot;this is my var&quot;
}

PLAY RECAP **********************************************************************************************
host_ccc                   : ok=3    changed=0    unreachable=0    failed=0"><pre class="notranslate"><code class="notranslate">(ansible-dev) ➜  ansible-bug-inventory-01 git:(master) ansible-playbook -i inventory pb.show_var.yaml --limit=host_ccc

PLAY [Print Variables] **********************************************************************************************

TASK [Variables for dev_aaa] **********************************************************************************************
ok: [host_ccc] =&gt; {
    "hostvars['host_aaa'].myvar": "VARIABLE IS NOT DEFINED!" &lt;&lt;&lt;&lt;&lt;
}

TASK [Variables for dev_bbb] **********************************************************************************************
ok: [host_ccc] =&gt; {
    "hostvars['host_bbb'].myvar": "VARIABLE IS NOT DEFINED!" &lt;&lt;&lt;&lt;&lt;&lt;
}

TASK [Variables for dev_ccc (self)] **********************************************************************************************
ok: [host_ccc] =&gt; {
    "myvar": "this is my var"
}

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

(ansible-dev) ➜  ansible-bug-inventory-01 ansible-playbook -i inventory.ini pb.show_var.yaml --limit=host_ccc

PLAY [Print Variables] *********************************************************************************************

TASK [Variables for dev_aaa] **********************************************************************************************
ok: [host_ccc] =&gt; {
    "hostvars['host_aaa'].myvar": "this is my var"
}

TASK [Variables for dev_bbb] **********************************************************************************************
ok: [host_ccc] =&gt; {
    "hostvars['host_bbb'].myvar": "this is my var"
}

TASK [Variables for dev_ccc (self)] **********************************************************************************************
ok: [host_ccc] =&gt; {
    "myvar": "this is my var"
}

PLAY RECAP **********************************************************************************************
host_ccc                   : ok=3    changed=0    unreachable=0    failed=0
</code></pre></div>