# How can i include other var files in a yaml file with only variables defined

**URL:** <https://forum.ansible.com/t/how-can-i-include-other-var-files-in-a-yaml-file-with-only-variables-defined/22864>\
**Category:** Ansible Project\
**Created:** [October 24, 2016, 11:57am UTC](https://forum.ansible.com/t/how-can-i-include-other-var-files-in-a-yaml-file-with-only-variables-defined/22864 "2016-10-24T11:57:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ishan\_jain](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@ishan\_jain](https://forum.ansible.com/u/ishan_jain)\
**Post date:** [October 24, 2016, 11:57am UTC](https://forum.ansible.com/t/how-can-i-include-other-var-files-in-a-yaml-file-with-only-variables-defined/22864/1 "2016-10-24T11:57:15Z")

</div>

Hi,

I use simple YAML files for defining some constant values to be used in my playbooks. A typical file would look like this:

var1: abc  
var2: xyz  
var3:

- item1
- item2  
var4:  
4.1: a  
4.2: b

I simply include the the file(s) like above in my playbooks in vars: section and all the constant values are available to me. Now i have a situation where i would like to break my vars file into several sub categories and include them all in one main vars file. I expect that i will have to include this one var file and others would be imported by this var file. I used include statement to have this:

- include: subvars1.yaml
- include: subvars2.yaml

var1: abc  
var2: xyz  
var3:

- item1
- item2

But this one is failing with some syntax error message.  
How can i include another vars file into one vars only file ?

---

<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:** [October 24, 2016, 1:26pm UTC](https://forum.ansible.com/t/how-can-i-include-other-var-files-in-a-yaml-file-with-only-variables-defined/22864/2 "2016-10-24T13:26:58Z")

</div>

You cannot, YAML does not have an include feature.
