I have environment variable configured in /etc/sysconfig/airflow
PASSWORD=pass123
I am hoping to be able to use this in the Bash command within BashOperator so that the password will not be visible in the Airflow UI or log. The variable will then be used in the DAG task as below.
con = 'username/$PASSWORD@//ex01-db.mybiz.com:1521/dwh'
sqlcl_cmd = f"""/oracle/sqlcl/bin/sql -s {con} > /data/tmp/extract.csv <<EOF
SET SQLFORMAT CSV
SET FEEDBACK OFF
SET TERMOUT OFF
SET ECHO OFF
SELECT * FROM ORDER.DAILY_SALES;
EXIT
EOF
"""
BashOperator(
task_id = 'extract_order',
bash_command = sqlcl_cmd,
dag = dag
)
However, it's observed that the variable $PASSWORD
is not expanded by Bash, resulting in error. How do I correctly use environment variable to be passed to bash_command
in BashOperator.