From cf313cde963b36003830f9badb0877495d9228a3 Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Thu, 12 Jul 2012 00:43:51 -0400 Subject: [PATCH] Soft import of paramiko since we have the SSH and local connection types now. Packaging will still require it. --- lib/ansible/runner/connection/paramiko_ssh.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/ansible/runner/connection/paramiko_ssh.py b/lib/ansible/runner/connection/paramiko_ssh.py index add2d3a1fbf..b8bbe95e8b0 100644 --- a/lib/ansible/runner/connection/paramiko_ssh.py +++ b/lib/ansible/runner/connection/paramiko_ssh.py @@ -32,9 +32,14 @@ import random from ansible import errors # prevent paramiko warning noise # see http://stackoverflow.com/questions/3920502/ +HAVE_PARAMIKO=False with warnings.catch_warnings(): warnings.simplefilter("ignore") - import paramiko + try: + import paramiko + HAVE_PARAMIKO=True + except ImportError: + pass class ParamikoConnection(object): ''' SSH based connections with Paramiko ''' @@ -48,6 +53,10 @@ class ParamikoConnection(object): self.port = self.runner.remote_port def _get_conn(self): + + if not HAVE_PARAMIKO: + raise errors.AnsibleError("paramiko is not installed") + user = self.runner.remote_user ssh = paramiko.SSHClient()