# Variable file inclusion advice sought

**URL:** <https://forum.ansible.com/t/variable-file-inclusion-advice-sought/21135>\
**Category:** Ansible Project\
**Created:** [April 12, 2016, 4:31am UTC](https://forum.ansible.com/t/variable-file-inclusion-advice-sought/21135 "2016-04-12T04:31:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![iamroddo](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/iamroddo/32/321_2.png) [@iamroddo](https://forum.ansible.com/u/iamroddo)\
**Post date:** [April 12, 2016, 4:31am UTC](https://forum.ansible.com/t/variable-file-inclusion-advice-sought/21135/1 "2016-04-12T04:31:45Z")

</div>

I’m trying to create a playbook in which I have a single role though I expect this will expand with time. I want to load the variables in a file per play\_host. I think I can include the variable file with the same name as the host with .yml or .yaml suffix in ./host\_vars or ./group\_vars/\<role\_name\> relative to the location of the inventory. However Ansible complains that these host variable files are not found unless they are in the same directory as the main playbook and inventory file.

The variable files are in ./host\_vars. The main playbook & inventory are ./site.yml & ./hosts, the role playbook is ./\<role\_name\>/main.yml and is as below.

---

<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:** [April 14, 2016, 1:49pm UTC](https://forum.ansible.com/t/variable-file-inclusion-advice-sought/21135/2 "2016-04-14T13:49:20Z")

</div>

host\_vars/group\_vars can be relative to inventory or to play, but variable files in host\_vars/ or group\_vars/ are automatically included, no need to use include\_vars.

include\_vars is relative to play only, as it does not make sense to use it to include inventory host/group vars (as they are automatic).

---

<div class="post-metadata">

**Author:** ![Johannes\_Kastl](https://avatars.discourse-cdn.com/v4/letter/j/bbe5ce/32.png) [@Johannes\_Kastl](https://forum.ansible.com/u/Johannes_Kastl)\
**Post date:** [May 16, 2016, 9:06am UTC](https://forum.ansible.com/t/variable-file-inclusion-advice-sought/21135/3 "2016-05-16T09:06:05Z")

</div>

Shouldn't your main.yml file be in ./roles/\<role name\>/tasks/main.yml?

Johannes
