blob: 4f9622dca75592a685484484a9757f7746119f64 [file] [log] [blame]
:py:mod:`airflow.providers.ssh.operators.ssh`
=============================================
.. py:module:: airflow.providers.ssh.operators.ssh
Module Contents
---------------
Classes
~~~~~~~
.. autoapisummary::
airflow.providers.ssh.operators.ssh.SSHOperator
Attributes
~~~~~~~~~~
.. autoapisummary::
airflow.providers.ssh.operators.ssh.CMD_TIMEOUT
.. py:data:: CMD_TIMEOUT
:annotation: = 10
.. py:class:: SSHOperator(*, ssh_hook = None, ssh_conn_id = None, remote_host = None, command = None, timeout = None, conn_timeout = None, cmd_timeout = None, environment = None, get_pty = False, banner_timeout = 30.0, **kwargs)
Bases: :py:obj:`airflow.models.BaseOperator`
SSHOperator to execute commands on given remote host using the ssh_hook.
:param ssh_hook: predefined ssh_hook to use for remote execution.
Either `ssh_hook` or `ssh_conn_id` needs to be provided.
:param ssh_conn_id: :ref:`ssh connection id<howto/connection:ssh>`
from airflow Connections. `ssh_conn_id` will be ignored if
`ssh_hook` is provided.
:param remote_host: remote host to connect (templated)
Nullable. If provided, it will replace the `remote_host` which was
defined in `ssh_hook` or predefined in the connection of `ssh_conn_id`.
:param command: command to execute on remote host. (templated)
:param conn_timeout: timeout (in seconds) for maintaining the connection. The default is 10 seconds.
Nullable. If provided, it will replace the `conn_timeout` which was
predefined in the connection of `ssh_conn_id`.
:param cmd_timeout: timeout (in seconds) for executing the command. The default is 10 seconds.
:param timeout: (deprecated) timeout (in seconds) for executing the command. The default is 10 seconds.
Use conn_timeout and cmd_timeout parameters instead.
:param environment: a dict of shell environment variables. Note that the
server will reject them silently if `AcceptEnv` is not set in SSH config.
:param get_pty: request a pseudo-terminal from the server. Set to ``True``
to have the remote process killed upon task timeout.
The default is ``False`` but note that `get_pty` is forced to ``True``
when the `command` starts with ``sudo``.
:param banner_timeout: timeout to wait for banner from the server in seconds
.. py:attribute:: template_fields
:annotation: :Sequence[str] = ['command', 'remote_host']
.. py:attribute:: template_ext
:annotation: :Sequence[str] = ['.sh']
.. py:attribute:: template_fields_renderers
.. py:method:: get_hook(self)
.. py:method:: get_ssh_client(self)
.. py:method:: exec_ssh_client_command(self, ssh_client, command)
.. py:method:: raise_for_status(self, exit_status, stderr)
.. py:method:: run_ssh_client_command(self, ssh_client, command)
.. py:method:: execute(self, context=None)
This is the main method to derive when creating an operator.
Context is the same dictionary used as when rendering jinja templates.
Refer to get_template_context for more context.
.. py:method:: tunnel(self)
Get ssh tunnel