Having problems passing parameters to an external bash script from a BashOperator. When I run a local command, the params are substituted correctly:
log_cleanup = """ echo "{{ params.BASE_LOG_FOLDER }}" """
log_cleanup_task = BashOperator(
task_id='log_cleanup_task',
provide_context=True,
bash_command = log_cleanup,
params = {'BASE_LOG_FOLDER': "/var/opt"},
dag=dagInstance,
)
prints: "/var/opt" (without the double quotes)
But if I call an external bash script, the params don't substitute in.
log_cleanup_task = BashOperator(
task_id='log_cleanup_task',
provide_context=True,
bash_command= str(DAGS_FOLDER)+"/scripts/log_cleanup.sh ",
params = {'BASE_LOG_FOLDER': "/var/opt" },
dag=dagInstance,
)
#log_cleanup.sh:
#! /usr/bin/bash
echo "{{ params.BASE_LOG_FOLDER }}"
prints: "{{ params.BASE_LOG_FOLDER }}" (without the double quotes)
In the external bash script, I can't get the parameters to substitute in like they do when the statement is stored within the DAG .py script.
Do I have to pass the params as command line arguments instead? Does the jinja templating only works in the .py files?
echo {{ params.BASE_LOG_FOLDER }}i.e by removing quotes around it - kaxil[2020-02-25 21:10:36,904] {bash_operator.py:128} INFO - {{ params.BASE_LOG_FOLDER }}- wolf2600