From e33f1777fe3d36cb957662b9701f5cf949d5f96f Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Wed, 28 Mar 2018 11:04:06 -0500 Subject: [PATCH] Backport #37646 for 2.5 (#37653) * Fix py3 issue in wait_for_connection (#37646) (cherry picked from commit 6c3e565ba3e71dbba695c675e98cfaaee8aa0727) * Add changelog entry for #36470 --- changelogs/fragments/py3-wait-for-connection.yaml | 2 ++ lib/ansible/plugins/action/wait_for_connection.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/py3-wait-for-connection.yaml diff --git a/changelogs/fragments/py3-wait-for-connection.yaml b/changelogs/fragments/py3-wait-for-connection.yaml new file mode 100644 index 00000000000..652789b6ce9 --- /dev/null +++ b/changelogs/fragments/py3-wait-for-connection.yaml @@ -0,0 +1,2 @@ +bugfixes: +- wait_for_connection - Fix python3 compatibility bug (https://github.com/ansible/ansible/pull/37646) diff --git a/lib/ansible/plugins/action/wait_for_connection.py b/lib/ansible/plugins/action/wait_for_connection.py index 1f777e8b81d..45473684b04 100644 --- a/lib/ansible/plugins/action/wait_for_connection.py +++ b/lib/ansible/plugins/action/wait_for_connection.py @@ -54,11 +54,12 @@ class ActionModule(ActionBase): display.debug("wait_for_connection: %s success" % what_desc) return except Exception as e: + error = e # PY3 compatibility to store exception for use outside of this block if what_desc: display.debug("wait_for_connection: %s fail (expected), retrying in %d seconds..." % (what_desc, sleep)) time.sleep(sleep) - raise TimedOutException("timed out waiting for %s: %s" % (what_desc, e)) + raise TimedOutException("timed out waiting for %s: %s" % (what_desc, error)) def run(self, tmp=None, task_vars=None): if task_vars is None: