What are Jinja2 tests, and which ones are most useful?
BeginnerConceptJinja2, Conditionals and Loops
Answer
Tests are used with is and return a boolean:
is defined/is undefinedis none,is string,is mapping,is iterableis match('regex'),is search('regex')is success,is failed,is changed,is skipped(on registered results)is file,is directory(about paths on the control node)is version('x.y', '>=')
when: result is failed
when: myvar is not defined
More on Jinja2, Conditionals and Loops
What role does Jinja2 play in Ansible?BeginnerWhat are the three Jinja2 delimiters?BeginnerShow a template with a loop and a conditional, and how it is deployed.BeginnerWhich filters do you use every day?BeginnerHow do you transform lists and dicts with filters (`map`, `select`, `selectattr`, `unique`, `flatten`)?IntermediateHow does `when` work and which operators can you use?Beginner