Store and access password using Apache airflow

前端 未结 6 1891
忘了有多久
忘了有多久 2020-12-25 11:43

We are using airflow as a scheduler. I want to invoke a simple bash operator in a DAG. The bash script needs password as an argument to do further processing.

How c

6条回答
  •  一向
    一向 (楼主)
    2020-12-25 11:58

    You can store the password in airflow variables, https://airflow.incubator.apache.org/ui.html#variable-view

    1. Create a variable with key&value in UI, for example, mypass:XXX
    2. Import Variable from airflow.models import Variable
    3. MyPass = Variable.get("mypass")
    4. Pass MyPass to your bash script:
    command = """
              echo "{{ params.my_param }}"
              """
    
    
    
    task = BashOperator(
            task_id='templated',
            bash_command=command,
            params={'my_param': MyPass},
            dag=dag)
    

提交回复
热议问题