airflowairflow-2.x

Airflow variable masking the value "airflow"


I am exploring airflow variables and created a variable in Airflow whose value has the word 'airflow' in it:

var_source_path = /opt/airflow/

While using this variable in my task, the word airflow is being masked with asterisk (***) as below:

Task:

t1 = BashOperator(task_id = 'echo_source_path',
                    bash_command = 'echo {{ var.value.var_source_path }}',
                    dag = dag
                    )

Log:

[2022-01-24 12:56:45,937] {subprocess.py:63} INFO - Running command: ['bash', '-c', 'echo /opt/***/']
[2022-01-24 12:56:45,948] {subprocess.py:75} INFO - Output:
[2022-01-24 12:56:45,982] {subprocess.py:79} INFO - /opt/***/
[2022-01-24 12:56:45,984] {subprocess.py:83} INFO - Command exited with return code 0

What is the reason behind this behaviour. Is there any config to control this.

P.S: I have set the Airflow metadata user/password as airflow:

    environment:
      MYSQL_ROOT_USER: airflow
      MYSQL_ROOT_PASSWORD: airflow
      MYSQL_USER: airflow
      MYSQL_PASSWORD: airflow
      MYSQL_DATABASE: airflow

Is this the root cause of this behaviour ?


Solution

  • Airflow 2.1+ masks sensitive passwords by default.

    It means that (indeed) you are using airflow as password somewhere (which you should not)

    See here for description on how it works and how you can disable it:

    https://airflow.apache.org/docs/apache-airflow/stable/security/secrets/mask-sensitive-values.html