# include\_vars look up files in wrong directory if used with local\_action

**URL:** <https://forum.ansible.com/t/include-vars-look-up-files-in-wrong-directory-if-used-with-local-action/20102>\
**Category:** Ansible Project\
**Created:** [December 30, 2015, 1:20pm UTC](https://forum.ansible.com/t/include-vars-look-up-files-in-wrong-directory-if-used-with-local-action/20102 "2015-12-30T13:20:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paulo\_Suderio](https://avatars.discourse-cdn.com/v4/letter/p/b3f665/32.png) [@Paulo\_Suderio](https://forum.ansible.com/u/Paulo_Suderio)\
**Post date:** [December 30, 2015, 1:20pm UTC](https://forum.ansible.com/t/include-vars-look-up-files-in-wrong-directory-if-used-with-local-action/20102/1 "2015-12-30T13:20:02Z")

</div>

I believe it is a bug, but since I am an ansible beginner I would like to check with someone before reporting - either for comfirmation or some indication that I am doing it the wrong way:

I am trying to load some variables from files in a role. The names of files are stored in a variable, in the same role. Thing is, I try to run the include\_vars as a local\_action.

**roles/common/vars/main.yml:**  
`  
x:

- aaa
- bbb  
`

**roles/common/tasks/main.yml:**

`

- name: include vars w/ local\_action  
local\_action: include\_vars “{{item}}.yml”  
with\_items: “{{x}}”  
`

**site.yml:**

`

- name: common stuff  
hosts: all  
gather\_facts: no  
roles:
- common  
`

This should, afaik, load the variables defined in files roles/common/vars/aaa.yml and roles/common/vars/bbb.yml. But when I runansible-playbook site.yml the files are searched in ./ instead of in roles/common/vars:

TASK [common: include vars w/ local\_action] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
task path: /home/ansible/roles/dsv/tasks/main.yml:12  
failed: [my.host → localhost] =\> (item=aaa) =\> {“failed”: true, “file”: “/home/ansible/aaa.yml”, “invocation”: {“module\_args”: {“\_raw\_params”: “"aaa.yml"”}, “module\_name”: “include\_vars”}, “item”: “aaa”, “msg”: “Source file not found.”}

Is this an expected behaviour or a bug, taking into account that when I do the include\_vars without the local\_action everything works fine?

BTW, the above example is a test case I made to show the problem in a simple way. This error showed up in a real use case a lot more complex. I am using ansible 2.0.0.

Thanks in advance.

Paulo Suderio

---

<div class="post-metadata">

**Author:** ![chrismeyersfsu](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/chrismeyersfsu/32/1016_2.png) [@chrismeyersfsu](https://forum.ansible.com/u/chrismeyersfsu)\
**Post date:** [December 31, 2015, 9:55pm UTC](https://forum.ansible.com/t/include-vars-look-up-files-in-wrong-directory-if-used-with-local-action/20102/2 "2015-12-31T21:55:18Z")

</div>

Paulo,

Does 1.9.4 behave in the same "inconsistent" way?

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [January 1, 2016, 5:45am UTC](https://forum.ansible.com/t/include-vars-look-up-files-in-wrong-directory-if-used-with-local-action/20102/3 "2016-01-01T05:45:33Z")

</div>

include vars is ALWAYS a 'local' action, you don't need to add that  
nor delegate\_to: localhost, it works the same as a include,add\_host,  
etc, these are all actions done on the ansible master on behalf of the  
inventory\_hostname, there is not need to 'localize' them.

So this 'might' be a bug, as the local action should be ignored, but  
might be changing the 'cwd' of the task and confusing the include  
mechanism.

---

<div class="post-metadata">

**Author:** ![einar.coutin](https://avatars.discourse-cdn.com/v4/letter/e/34f0e0/32.png) [@einar.coutin](https://forum.ansible.com/u/einar.coutin)\
**Post date:** [July 5, 2016, 6:29pm UTC](https://forum.ansible.com/t/include-vars-look-up-files-in-wrong-directory-if-used-with-local-action/20102/4 "2016-07-05T18:29:53Z")

</div>

Brian,

I’m having the same problem on Ansible 2.0.2 without local action. I’m running on tower
