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\'
you don't need to set var, because I'm guessing that you trying to set var for some condition later. Just make condition there like
- name: Later task shell: "command is here" when: {{ existing_ansible_var }} == "string1"
and get a profit