<h5 dir="auto">ISSUE TYPE</h5>
<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">ANSIBLE VERSION</h5>
<p dir="auto">ansible 2.1.1.0<br>
config file = /etc/ansible/ansible.cfg<br>
configured module search path = Default w/o overrides</p>
<h5 dir="auto">CONFIGURATION</h5>
<p dir="auto">custom role_path</p>
<h5 dir="auto">OS / ENVIRONMENT</h5>
<p dir="auto">Ubuntu 12.04</p>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">After upgrade from 2.1.0 to 2.1.1 cannot use group_vars and host_vars in role's defined playbook</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>
<p dir="auto">$ ansible-playbook -i hosts playbooks/playbook.yml<br>
Enter hosts for playbook run: test_group</p>
<p dir="auto">PLAY [Test playbook] ***********************************************************</p>
<p dir="auto">TASK [setup] *******************************************************************<br>
ok: [10.10.10.5]<br>
ok: [10.10.10.6]</p>
<p dir="auto">TASK [common-aliases : set alias] **********************************************<br>
fatal: [10.10.10.5]: FAILED! =&gt; {"failed": true, "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'root_mail_aliase' is undefined\n\nThe error appears to have been in '/home/snow/Documents/scripts/ansible/roles/common-aliases/tasks/main.yml': line 2, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n---\n- name: set alias\n  ^ here\n"}<br>
fatal: [10.10.10.6]: FAILED! =&gt; {"failed": true, "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'root_mail_aliase' is undefined\n\nThe error appears to have been in '/home/snow/Documents/scripts/ansible/roles/common-aliases/tasks/main.yml': line 2, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n---\n- name: set alias\n  ^ here\n"}</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ cat playbook.yml

---
- name: Test playbook
  hosts: &quot;{{ hosts }}&quot;
  user: root
  gather_facts: True
  vars_prompt:
    - name: hosts
      prompt: &quot;Enter hosts for playbook run&quot;
      private: no


  roles:
#check host_vars/ before run
#check group_vars/ before run
      - common-aliases

$ cat group_vars/test_group
root_mail_aliase: &quot;admins@example.com&quot;

$ cat /home/snow/Documents/scripts/ansible/roles/common-aliases/tasks/main.yml

---
- name: set alias
  lineinfile: &quot;dest=/etc/aliases insertafter='^#root:' line='root:       {{ root_mail_aliase }}'&quot;"><pre class="notranslate"><code class="notranslate">$ cat playbook.yml

---
- name: Test playbook
  hosts: "{{ hosts }}"
  user: root
  gather_facts: True
  vars_prompt:
    - name: hosts
      prompt: "Enter hosts for playbook run"
      private: no


  roles:
#check host_vars/ before run
#check group_vars/ before run
      - common-aliases

$ cat group_vars/test_group
root_mail_aliase: "admins@example.com"

$ cat /home/snow/Documents/scripts/ansible/roles/common-aliases/tasks/main.yml

---
- name: set alias
  lineinfile: "dest=/etc/aliases insertafter='^#root:' line='root:       {{ root_mail_aliase }}'"
</code></pre></div>
<h5 dir="auto">EXPECTED RESULTS</h5>
<p dir="auto">Variable root_mail_aliase can be accessible from task</p>
<h5 dir="auto">ACTUAL RESULTS</h5>
<p dir="auto">Running the playbook leads to the error above</p>
<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.1.0"><pre class="notranslate"><code class="notranslate">ansible 2.1.1.0
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>
<h5 dir="auto">OS / ENVIRONMENT</h5>
<p dir="auto">Ubuntu 16.04</p>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">group_vars are ignored if the inventory is the output of a script that is stored in a subdirectory. This includes the popular ec2 inventory script. This bug was introduced in 2.1.1.0 (2.1.0.0 works fine).</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>
<h6 dir="auto"><code class="notranslate">inventory/script.sh</code></h6>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="#!/bin/sh

echo '{&quot;webservers&quot;: [&quot;paperberry&quot;]}'"><pre class="notranslate"><code class="notranslate">#!/bin/sh

echo '{"webservers": ["paperberry"]}'
</code></pre></div>
<h6 dir="auto"><code class="notranslate">group_vars/all.yml</code>:</h6>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="
---
frontend_path: /var/www/html"><pre class="notranslate"><code class="notranslate">
---
frontend_path: /var/www/html
</code></pre></div>
<h6 dir="auto"><code class="notranslate">playbooks/webservers.yml</code>:</h6>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="
---
- hosts: all
  connection: local
  tasks:
  - debug: var=frontend_path"><pre class="notranslate"><code class="notranslate">
---
- hosts: all
  connection: local
  tasks:
  - debug: var=frontend_path
</code></pre></div>
<p dir="auto">Run the following code:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible-playbook -i inventory/script.sh playbooks/webservers.yml "><pre class="notranslate"><code class="notranslate">ansible-playbook -i inventory/script.sh playbooks/webservers.yml 
</code></pre></div>
<h5 dir="auto">EXPECTED RESULTS</h5>
<p dir="auto">ansible 2.1.0.0 shows</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ok: [paperberry] =&gt; {
    &quot;frontend_path&quot;: &quot;/var/www/html&quot;
}"><pre class="notranslate"><code class="notranslate">ok: [paperberry] =&gt; {
    "frontend_path": "/var/www/html"
}
</code></pre></div>
<h5 dir="auto">ACTUAL RESULTS</h5>
<p dir="auto">ansible 2.1.1.0 shows</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ok: [paperberry] =&gt; {
    &quot;frontend_path&quot;: &quot;VARIABLE IS NOT DEFINED!&quot;
}"><pre class="notranslate"><code class="notranslate">ok: [paperberry] =&gt; {
    "frontend_path": "VARIABLE IS NOT DEFINED!"
}
</code></pre></div>