Case statement for setting var in Ansible/Jinja2
I'm using Ansible with Jinja2 templates, and this is a scenario that I can't find a solution for in Ansible's documentation or googling around for Jinja2 examples. Here's the logic that I want to achieve in Ansible: if {{ existing_ansible_var }} == "string1" new_ansible_var = "a" else if {{ existing_ansible_var }} == "string2" new_ansible_var = "b" <...> else new_ansible_var = "" I could probably do this by combining several techniques, the variable assignment from here: Set variable in jinja , the conditional comparison here: http://jinja.pocoo.org/docs/dev/templates/#if-expression , and the