# How do I include vars.yml in playbook or tasks - main.yml

**URL:** <https://forum.ansible.com/t/how-do-i-include-vars-yml-in-playbook-or-tasks-main-yml/25473>\
**Category:** Ansible Project\
**Created:** [September 13, 2017, 11:59am UTC](https://forum.ansible.com/t/how-do-i-include-vars-yml-in-playbook-or-tasks-main-yml/25473 "2017-09-13T11:59:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vijay\_R](https://avatars.discourse-cdn.com/v4/letter/v/67e7ee/32.png) [@Vijay\_R](https://forum.ansible.com/u/Vijay_R)\
**Post date:** [September 13, 2017, 11:59am UTC](https://forum.ansible.com/t/how-do-i-include-vars-yml-in-playbook-or-tasks-main-yml/25473/1 "2017-09-13T11:59:47Z")

</div>

Hi All,

I am trying to include variables that I have defined under roles/var/var.yml in roles/conf/tasks/main.yml, but I am not able to do it.

**roles/conf/tasks/main.yml**

`

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [September 13, 2017, 2:59pm UTC](https://forum.ansible.com/t/how-do-i-include-vars-yml-in-playbook-or-tasks-main-yml/25473/2 "2017-09-13T14:59:39Z")

</div>

> Hi All,
> 
> I am trying to include variables that I have defined under  
> roles/var/var.yml in roles/conf/tasks/main.yml, but I am not able to do it.
> 
> \*roles/conf/tasks/main.yml\*
> 
> ---  
> - name: vars  
> &nbsp;&nbsp;include\_vars: var.yml

Here you are using var.yml...

> - name: Changes for sysctl file  
> &nbsp;&nbsp;shell:  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo -e "\n###For Cloudera###" \>\> /etc/sysctl.conf
> 
> Note: I have tried like these all possibilities ({{ var }}.yml, var.yml),  
> but none worked.
> 
> \*roles/vars/vars.yml\*

...but here the file is called vars.yml

> What am I missing here?

I would guess your error message would give you this clue.
