From d043ba2673d20eb84b2d1d895c0e8033ec9b303e Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Thu, 7 Sep 2017 12:15:31 -0500 Subject: [PATCH] Create a new pipe for sshpass on retries. Fixes #29095 --- lib/ansible/plugins/connection/ssh.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/ansible/plugins/connection/ssh.py b/lib/ansible/plugins/connection/ssh.py index 6b3d1ab3fab..7f6a2363591 100644 --- a/lib/ansible/plugins/connection/ssh.py +++ b/lib/ansible/plugins/connection/ssh.py @@ -182,6 +182,12 @@ def _ssh_retry(func): remaining_tries = int(C.ANSIBLE_SSH_RETRIES) + 1 cmd_summary = "%s..." % args[0] for attempt in range(remaining_tries): + cmd = args[0] + if attempt != 0 and self._play_context.password and isinstance(cmd, list): + # If this is a retry, the fd/pipe for sshpass is closed, and we need a new one + self.sshpass_pipe = os.pipe() + cmd[1] = b'-d' + to_bytes(self.sshpass_pipe[0], nonstring='simplerepr', errors='surrogate_or_strict') + try: try: return_tuple = func(self, *args, **kwargs)