Error:: AnsibleUndefinedVariable

20 views
Skip to first unread message

Vipul Vadoliya

unread,
Oct 21, 2016, 5:24:34 AM10/21/16
to Ansible Project
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...!!!

Brian Coca

unread,
Oct 21, 2016, 3:01:10 PM10/21/16
to ansible...@googlegroups.com
Not enough context to answer, your vars file needs to be made available to the play in some form before templates can use it.


----------
Brian Coca
Reply all
Reply to author
Forward
0 new messages