# How to specify variables to be used in roles?

**URL:** <https://forum.ansible.com/t/how-to-specify-variables-to-be-used-in-roles/22623>\
**Category:** Ansible Project\
**Created:** [September 23, 2016, 9:25am UTC](https://forum.ansible.com/t/how-to-specify-variables-to-be-used-in-roles/22623 "2016-09-23T09:25:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chethan\_S](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@Chethan\_S](https://forum.ansible.com/u/Chethan_S)\
**Post date:** [September 23, 2016, 9:25am UTC](https://forum.ansible.com/t/how-to-specify-variables-to-be-used-in-roles/22623/1 "2016-09-23T09:25:29Z")

</div>

I am in the process of migrating to Ansible roles model and I have the following structure -

**…/roles/vms/tasks/main.yml**

`

---

<div class="post-metadata">

**Author:** ![ZillaYT](https://avatars.discourse-cdn.com/v4/letter/z/4da419/32.png) [@ZillaYT](https://forum.ansible.com/u/ZillaYT)\
**Post date:** [September 23, 2016, 6:14pm UTC](https://forum.ansible.com/t/how-to-specify-variables-to-be-used-in-roles/22623/2 "2016-09-23T18:14:00Z")

</div>

What is your file structure? You show a vms role, but not a vmcreation role, but yet your playbook includes the vmcreation role?

---

<div class="post-metadata">

**Author:** ![ZillaYT](https://avatars.discourse-cdn.com/v4/letter/z/4da419/32.png) [@ZillaYT](https://forum.ansible.com/u/ZillaYT)\
**Post date:** [September 23, 2016, 6:36pm UTC](https://forum.ansible.com/t/how-to-specify-variables-to-be-used-in-roles/22623/3 "2016-09-23T18:36:58Z")

</div>

I think I know what you’re after. Try this.

Have two files in …/roles/vms/vars, namely,

**…/roles/vms/vars/vmname81.yml**  
`

---

<div class="post-metadata">

**Author:** ![ZillaYT](https://avatars.discourse-cdn.com/v4/letter/z/4da419/32.png) [@ZillaYT](https://forum.ansible.com/u/ZillaYT)\
**Post date:** [September 23, 2016, 6:40pm UTC](https://forum.ansible.com/t/how-to-specify-variables-to-be-used-in-roles/22623/4 "2016-09-23T18:40:52Z")

</div>

Sorry, the include\_vars should be:

`

- include\_vars: “vars/vmname{{ windows\_ver }}.yml”  
`

---

<div class="post-metadata">

**Author:** ![Chethan\_S](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@Chethan\_S](https://forum.ansible.com/u/Chethan_S)\
**Post date:** [September 24, 2016, 2:28am UTC](https://forum.ansible.com/t/how-to-specify-variables-to-be-used-in-roles/22623/5 "2016-09-24T02:28:32Z")

</div>

Thank you, Zilla. I got a simpler solution for this question which I posted at [Stack Overflow](http://stackoverflow.com/a/39657819/553023) wherein I didn’t have to split vars files. I have had success following it.
