Hi,
Having simple template file with bash valid content like:
${#ArrayName[@]}
will break template module:
- template: src=template dest=template2
TASK: [template src=template dest=template2] **********************************
fatal: [127.0.0.1] => {‘msg’: ‘Missing end of comment tag’, ‘failed’: True}
fatal: [127.0.0.1] => {‘msg’: ‘Missing end of comment tag’, ‘failed’: True}
Is there any workaround for this?
{# #} is a jinja comment tag which is why it is gettitng confused here
try:
{{ ‘${#ArrayName[@]}’ }}
Works great! Thanks a lot Brian.
ric1
4
You can also wrap an entire block text/code in {% raw %} {% endraw %}:
{% raw %}
for (( 1=0; i<$#allowed_list[@]}; i++ )); do
allowed=${allowed_list[$i]
do something here with $allowed
done
{% endraw %}
This allows you to avoid escaping all the dollar signs, as well…
-Ric
It gets even more interesting if you get something like this:
define(‘AUTH_KEY’, 'TccKCkdkq.}]I]I?$(.R@L)ASUysg% AB(a5j+`A8_ra6Vu7D*h2Q]||}.{#b}5Xq’);
Because the ; makes the engine throw this error:
expected token ‘end of print statement’, got ‘;’
Hit something similar when pushing go templates out with the ansible
template command.
Use
{%raw%}
..... line noise goes here ....
{%endraw%}