Just solved - the conn_id has to be in ' ', like ssh01 = SSHHook(conn_id='ssh_01')
Works like a charm, --alex > On Jul 6, 2016, at 11:54 AM, Alexander Alten-Lorenz <[email protected]> > wrote: > > Good morning, > > I try to use the SSHExecutors, but struggle with more than one connection > (conn_id). I have different ssh connections in Airflow => Admin => > Connections, but when I try to them in my SSH DAG I get (as example): > > name 'ssh_01' is not defined > > Here's my badly script: > > from airflow import DAG > from airflow.operators.bash_operator import BashOperator > from airflow.contrib.operators import SSHExecuteOperator > from airflow.contrib.hooks import SSHHook > from datetime import datetime, time delta > > default_args = { > 'owner': 'me', > 'depends_on_past': False, > 'start_date': datetime(2016, 7, 5), > # 'email': ['[email protected]'], > 'email_on_failure': False, > 'email_on_retry': False, > 'retries': 1, > 'retry_delay': timedelta(minutes=5), > # 'queue': 'bash_queue', > # 'pool': 'backfill', > # 'priority_weight': 10, > # 'end_date': datetime(2016, 1, 1), > } > > dag = DAG('ssh_test', default_args=default_args, schedule_interval='@weekly') > ssh01 = SSHHook(conn_id=ssh_01) > > # SSH connect > t1 = SSHExecuteOperator( > task_id='check_01', > ssh_hook = ssh01, > bash_command="/sbin/initctl list |grep fork-sec2", > dag=dag) > > thanks for any advise, > --alex > >
