From fe2eb2ae4aeb4812fa2f59ccdfabc9efc677e657 Mon Sep 17 00:00:00 2001 From: Piotr Smolinski Date: Wed, 31 May 2017 14:28:08 +0200 Subject: [PATCH] added status code check In the existing implementation when the ssh command fails the command result is silently discarded. It hides the fact that the disconnection did not go as expected. Effectively the intended action was not successful, but the play continues. --- lib/ansible/plugins/connection/ssh.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/ansible/plugins/connection/ssh.py b/lib/ansible/plugins/connection/ssh.py index 2ddb5ffe956..5cc3fc71095 100644 --- a/lib/ansible/plugins/connection/ssh.py +++ b/lib/ansible/plugins/connection/ssh.py @@ -897,6 +897,8 @@ class Connection(ConnectionBase): display.vvv(u'sending stop: %s' % cmd) p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = p.communicate() + status_code = p.wait() + if status_code != 0: self.close()