天津做網(wǎng)站就到徽信xiala5如何制作網(wǎng)站二維碼
拷貝模板時(shí)報(bào)錯(cuò):AnsibleError: template error while templating string: Missing end of comment tag.
原因
shell腳本中地{#和jinja中的語法comment tag相同,而且只有一半,導(dǎo)致無法渲染導(dǎo)致。
解決
在有語法沖突的地方使用組合標(biāo)簽{% raw %} 、{% endraw %}包裹起來,例如:
{% raw %}if [[ ${#info_array[*]} -ne 3 ]];thenecho "ERROR:${info} Format Error,Please Excute:bash $0 -h" && exit 1fi
{% endraw %}
拷貝模板時(shí)報(bào)錯(cuò):AnsibleError: template error while templating string: expected token ‘:’, got ‘}’. String
錯(cuò)誤的寫法:
{% if {{ db_type}} == "mysql" %}
a=1
{% endif %}
正確的寫法:
{% if db_type == "mysql" %}
a=1
{% endif %}
總結(jié):在if,for等條件判斷語句中變量不需加{{ }}