I am putting broker: true and zookeeper: true in inventory file but i still getting below exception as its referred in j2 file
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ansible.errors.AnsibleUndefinedVariable: ‘broker’ is undefined. ‘broker’ is undefined
fatal: [en1qa1-zookpr02.qa]: FAILED! => {“changed”: false, “msg”: “AnsibleUndefinedVariable: ‘broker’ is undefined. ‘broker’ is undefined”}
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ansible.errors.AnsibleUndefinedVariable: ‘broker’ is undefined. ‘broker’ is undefined
fatal: [en1qa1-zookpr01.qa: FAILED! => {“changed”: false, “msg”: “AnsibleUndefinedVariable: ‘broker’ is undefined. ‘broker’ is undefined”}
The messages are correct. You have only defined the “broker” variable on one set of hosts, and the two hosts indicated in the errors are not in that set.
You can fix this in a couple of ways. One way is to define all three variables in all three sets of hosts:
The other way is to define all three variables in a higher group, setting them all to false, say, and then at the host level set only the ones you want to be true to true:
This creates three additional host groups: qa_eng_zoo, qa_eng_bro, and qa_end_sch. In your templates and whatnot, you can simply check for group membership.