I'm running an if
statement in a bash script. And I need to deploy the bash script in a different server. Below is my if else statement.
DIR="/backup/db"
first_time=true
{% if [ -d "$DIR" ]; then %}
first_time=false
sudo -u tomcat ln -s /backup/app /opt/tomcat/latest/webapps/msales
sudo -u tomcat ln -s /backup/store/logs /opt/tomcat/latest/logs
.....etc
{% fi %}
I'm using Ansible to deploy to this script.sh.j2 to the other server. But it says
""msg": "AnsibleError: template error while templating string: expected token ',', got 'string'."
How to use if statements in j2 templates?