Search code examples
airflowairflow-scheduler

Airflow-Installation User issue


We have installed airflow in linux environment after creating virtual environment. It was installed as root user. All the installed files were created with root permission.

In dag, we are using BashOperator, where python script is called as bash command. This script supposed to run as different user 'ABC'. I cannot trigger the airflow using this user.

While running dag, airflow is triggered as root by default, which causes the python script to run as root and script fails due to permission issues of folder structure.

Airflow should not triggered as root.

Cant we install the airflow, using user other than root? Kindly suggest the best practices to be followed for this case.


Solution

  • You have two options here: 1/ install airflow with another user (reconmmended) 2/ if you just want to execute script as different specific unix users, the BashOperator allows you to do it with the parameter "run_as_user":

    t1 = BashOperator(task_id='create_dir', bash_command='mkdir /tmp/airflow_dir_test', dag=dag, run_as_user='user1')