Reputation: 520
I would like to use Ansible to template a BASH file. But I have one line in my BASH to print array length:
if [ ${#my_array[@]} -gt 0 ]; then
Seems like Ansible has trouble handling this line, always returns an error:
ansible error template error while templating string missing end of comment tag
If I delete this line then the playbook can template the BASH successfully. How do I escape special characters in ansible jinja2 file? I am very new to Ansible, any help is appreciated!
Upvotes: 0
Views: 2456
Reputation: 520
I think I can use {% raw %}
{% raw %}
if [ ${#my_array[@]} -gt 0 ]; then
{% endraw %}
I am not sure if this is the best solution but at least it worked
Upvotes: 3