From 08f270ad712fc1842008c33f9e30e12768fe9bdd Mon Sep 17 00:00:00 2001 From: Devananda van der Veen Date: Wed, 9 Mar 2016 17:15:11 -0800 Subject: [PATCH] Send empty command before recv On some switches, starting an SSH connection and immediately calling recv() will result in a connection timeout. The switch requires some input on the channel before it provides any prompt. As such, this patch sends an empty command immediately upon connection, triggering the switch to send a prompt which the shell can then interpret. Signed-off-by: Devananda van der Veen --- lib/ansible/module_utils/shell.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/ansible/module_utils/shell.py b/lib/ansible/module_utils/shell.py index bcb88fa790b..5b946634576 100644 --- a/lib/ansible/module_utils/shell.py +++ b/lib/ansible/module_utils/shell.py @@ -109,6 +109,7 @@ class Shell(object): self.shell = self.ssh.invoke_shell() self.shell.settimeout(10) + self.shell.sendall("\n") self.receive() def strip(self, data):