# Subdirectories in host\_vars

**URL:** <https://forum.ansible.com/t/subdirectories-in-host-vars/31266>\
**Category:** Ansible Project\
**Created:** [September 11, 2019, 10:11pm UTC](https://forum.ansible.com/t/subdirectories-in-host-vars/31266 "2019-09-11T22:11:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Peter\_Kokot](https://avatars.discourse-cdn.com/v4/letter/p/d2c977/32.png) [@Peter\_Kokot](https://forum.ansible.com/u/Peter_Kokot)\
**Post date:** [September 11, 2019, 10:11pm UTC](https://forum.ansible.com/t/subdirectories-in-host-vars/31266/1 "2019-09-11T22:11:40Z")

</div>

Hello,

does host\_vars directory support subdirectories? So multiple variables can be organized in multiple YAML files inside the host subdirectory. For example:

├─ host\_vars/  
├─── hostname\_1.tld/

├───── secrets.yaml  
├───── variables.yaml  
├─── hostname\_2.tld/  
├───── secrets.yaml  
├───── other\_variables.yaml  
└─ …

Thank you for possible answers and helping out.

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [September 11, 2019, 10:27pm UTC](https://forum.ansible.com/t/subdirectories-in-host-vars/31266/2 "2019-09-11T22:27:09Z")

</div>

Yes.

---

<div class="post-metadata">

**Author:** ![Peter\_Kokot](https://avatars.discourse-cdn.com/v4/letter/p/d2c977/32.png) [@Peter\_Kokot](https://forum.ansible.com/u/Peter_Kokot)\
**Post date:** [September 11, 2019, 11:24pm UTC](https://forum.ansible.com/t/subdirectories-in-host-vars/31266/3 "2019-09-11T23:24:46Z")

</div>

Thank you so much for your answer.

Yes, it works correctly as expected. Issue was that I was overriding the variables from the roles incorrectly (roles/something/vars/main.yaml) and should use the roles/something/defaults/main.yaml for that. The host\_vars work as expected.

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [September 12, 2019, 7:04am UTC](https://forum.ansible.com/t/subdirectories-in-host-vars/31266/4 "2019-09-12T07:04:07Z")

</div>

Yup.  
I tend to use rolename/vars for things that are rather static.  
For instance, a dict of software versions and their checksums, which  
will never change.
