Am I using elif incorrectly?
template file: {% if myvar == "value1" %} name: "mysql_RO_3306-a" {% elif myvar = "value2" %} name: "mysql_RO_3306-b" {% else %} name: "mysql_RO_3306-c" {% endif %} playbook: --- - hosts: 127.0.0.1 connection: local tasks: - name: "create RO var file" template: src: foo.j2 dest: foo.yml results: ansible-playbook -i foo.inv foo.yml -e myvar=value1 PLAY [127.0.0.1] ************************************************************************************************************************************************************************************************** TASK [Gathering Facts] ******************************************************************************************************************************************************************************************** ok: [localhost] TASK [create RO var file] ***************************************************************************************************************************************************************************************** fatal: [localhost]: FAILED! => {"changed": false, "msg": "AnsibleError: template error while templating string: expected token 'end of statement block', got '='. String: {% if myvar == \"value1\" %}\nname: \"mysql_RO_3306-a\"\n{% elif myvar = \"value2\" %}\nname: \"mysql_RO_3306-b\"\n{% else %}\nname: \"mysql_RO_3306-c\"\n{% endif %}\n"} PLAY RECAP ******************************************************************************************************************************************************************************************************** localhost : ok=1 changed=0 unreachable=0 failed=1 -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/9d5c1de3-3a83-4f44-af5e-5a79d4f8a396%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.