I would like for 'when' to take the item to evaluate from the loop. How do i do it? Is it even possible?
---
hosts: servers
vars:
- a: True
- b: False
- c: True
tasks:
- name: ping it
ping:
when: letter == True
loop:
- { letter: 'a' }
- { letter: 'b' }
- { letter: 'c' }
Right now it fails with:
fatal: [127.0.0.1]: FAILED! => {"msg": "The conditional check 'letter == True' failed. The error was: error while evaluating conditional (letter == True): 'letter' is undefined
When I enclose letter in quotes and/or curly brackets, i get syntax error.
This is just an extremely simplified version of what i actually need to do, so please concentrate on the actual question, not that the loop is done in too complex a way or that the test could be done differently (in the final version i'll probably have values other than true/false and each loop line will have multiple key-value pairs.)