Interview Prep/Ansible/Jinja2, Conditionals and Loops

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 undefined
  • is none, is string, is mapping, is iterable
  • is 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
All Ansible questions Roadmap: Ansible

More on Jinja2, Conditionals and Loops