Reputation: 1
I have a problem
"AnsibleUndefinedVariable: One or more undefined variables: 'str object' has no attribute 'node1'", 'failed': True}
In Hosts :
[test]
192.168.1.1
In /etc/ansible/host_vars/192.168.1.1
nginx:
- { node1: "192.168.2.1" }
In /etc/ansible/roles/nginx/templates/site.j2
server {{ item.node1 }}:80;
Help me please why ansible can't read a host_vars files and put variable in template/ file. Thx
Upvotes: 0
Views: 400
Reputation: 3215
Your /etc/ansible/host_vars/192.168.1.1
should be
nginx:
node1: "192.168.2.1"
Upvotes: 1