I've defined a variable in my inventory file, but i get error variable is undefined when using it in play condition.
inventory.yml:
[nodes]
node1 ....
node1 ....
[cluster:children]
nodes
[cluster:vars]
somevar=False
testvar=value
playbook.yml:
- include: setup_whatever.yml
when: "testvar == 'value'"
run it with
ansible-playbook playbook.yml -i inventory
here is the error message i get
ERROR! The conditional check 'testvar == 'value'' failed. The error was: ERROR! error while evaluating conditional (testvar == 'value'): ERROR! 'testvar' is undefined
ansible version: 2.0.0.2
Upgrade your Ansible version to a modern one.
ERROR! The conditional check 'testvar == 'value'' failed. The error was:
ERROR! error while evaluating conditional (testvar == 'value'):
ERROR! 'testvar' is undefined
PLAY [nodes]
\*******************************************************************
TASK [debug]
\*******************************************************************
ok: [node1] => {
"msg": "Hello world!"
}