From 7eab802669de096252a04d5baa110914bef3d114 Mon Sep 17 00:00:00 2001 From: Gabor Lekeny Date: Sat, 16 Apr 2016 00:52:35 +0200 Subject: [PATCH] SSH fails with '"parsed": false' error message Fixes: #15436 --- lib/ansible/plugins/connection/ssh.py | 5 +++-- test/units/plugins/connection/test_ssh.py | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/ansible/plugins/connection/ssh.py b/lib/ansible/plugins/connection/ssh.py index 500c1a1b031..46f734da28c 100644 --- a/lib/ansible/plugins/connection/ssh.py +++ b/lib/ansible/plugins/connection/ssh.py @@ -610,6 +610,7 @@ class Connection(ConnectionBase): try: while True: + poll = p.poll() events = selector.select(timeout) # We pay attention to timeouts only while negotiating a prompt. @@ -619,7 +620,7 @@ class Connection(ConnectionBase): if state <= states.index('awaiting_escalation'): # If the process has already exited, then it's not really a # timeout; we'll let the normal error handling deal with it. - if p.poll() is not None: + if poll is not None: break self._terminate_process(p) raise AnsibleError('Timeout (%ds) waiting for privilege escalation prompt: %s' % (timeout, to_native(b_stdout))) @@ -721,7 +722,7 @@ class Connection(ConnectionBase): # Now we're awaiting_exit: has the child process exited? If it has, # and we've read all available output from it, we're done. - if p.poll() is not None: + if poll is not None: if not selector.get_map() or not events: break # We should not see further writes to the stdout/stderr file diff --git a/test/units/plugins/connection/test_ssh.py b/test/units/plugins/connection/test_ssh.py index 502d67b65c8..ef7632d579c 100644 --- a/test/units/plugins/connection/test_ssh.py +++ b/test/units/plugins/connection/test_ssh.py @@ -415,7 +415,7 @@ class TestSSHConnectionRun(object): self.conn._flags['become_success'] = True return (b'', b'') - def test_pasword_with_prompt(self): + def test_password_with_prompt(self): # test with password prompting enabled self.pc.password = None self.pc.prompt = b'Password:' @@ -440,7 +440,7 @@ class TestSSHConnectionRun(object): assert self.conn._send_initial_data.call_count == 1 assert self.conn._send_initial_data.call_args[0][1] == 'this is input data' - def test_pasword_with_become(self): + def test_password_with_become(self): # test with some become settings self.pc.prompt = b'Password:' self.pc.become = True @@ -550,8 +550,8 @@ class TestSSHConnectionRetries(object): monkeypatch.setattr('time.sleep', lambda x: None) - self.mock_popen_res.stdout.read.side_effect = [b""] * 11 - self.mock_popen_res.stderr.read.side_effect = [b""] * 11 + self.mock_popen_res.stdout.read.side_effect = [b""] * 10 + self.mock_popen_res.stderr.read.side_effect = [b""] * 10 type(self.mock_popen_res).returncode = PropertyMock(side_effect=[255] * 30) self.mock_selector.select.side_effect = [