我正在尝试使用SSHOperator通过气流连接到ec2实例,但是我的dag失败并显示以下错误消息:
[2020-05-24 06:17:04,191] {base_task_runner.py:98} INFO - Subtask: File "/usr/local/lib/python3.6/site-packages/airflow/contrib/operators/ssh_operator.py", line 146, in execute
[2020-05-24 06:17:04,191] {base_task_runner.py:98} INFO - Subtask: raise AirflowException("SSH operator error: {0}".format(str(e)))
[2020-05-24 06:17:04,191] {base_task_runner.py:98} INFO - Subtask: airflow.exceptions.AirflowException: SSH operator error: 'NoneType' object has no attribute 'exec_command'
这是我的源代码:
from airflow.contrib.operators.ssh_operator import SSHOperator
...
t1 = BashOperator(
task_id='print_date',
bash_command='date',
dag=DAG)
t2 = SSHOperator(
ssh_conn_id='my_ec2_connection',
task_id='ssh_operator',
command='ls',
dag=DAG)
t1 >> t2
我已经在UI中使用ssh连接设置了pem文件,并且还对pem密钥进行了ssh-add。