Error:: AnsibleUndefinedVariable

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…!!!

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