# Error:: AnsibleUndefinedVariable

**URL:** <https://forum.ansible.com/t/error-ansibleundefinedvariable/22852>\
**Category:** Ansible Project\
**Created:** [October 21, 2016, 9:24am UTC](https://forum.ansible.com/t/error-ansibleundefinedvariable/22852 "2016-10-21T09:24:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vipul\_Vadoliya](https://avatars.discourse-cdn.com/v4/letter/v/9f8e36/32.png) [@Vipul\_Vadoliya](https://forum.ansible.com/u/Vipul_Vadoliya)\
**Post date:** [October 21, 2016, 9:24am UTC](https://forum.ansible.com/t/error-ansibleundefinedvariable/22852/1 "2016-10-21T09:24:34Z")

</div>

hi guys i am getting below error  
“AnsibleUndefinedVariable: ‘web\_servers’ is undefined”

this is variables in vars file : vars/main.yml

web\_servers:

- {hostname: xxxxx1, ip: 192.168.0.1, port: 8080}
- {hostname: xxxxx2, ip: 192.168.0.2, port: 8080}

this cfg in templates: templates/main.yml

{% for server in web\_servers %}  
server {{ server.hostname }} {{ server.ip }}:{{ server.port }} check  
{% endfor %}

do i need to include default vars/main.yml file in templates/main.yml ?  
can any one suggest…!!!

---

<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 21, 2016, 7:01pm UTC](https://forum.ansible.com/t/error-ansibleundefinedvariable/22852/2 "2016-10-21T19:01:02Z")

</div>

Not enough context to answer, your vars file needs to be made available to the play in some form before templates can use it.
