From 85bba04a1c7e411b557f6856ba2775496cef1c99 Mon Sep 17 00:00:00 2001 From: Dag Wieers Date: Tue, 20 Nov 2012 19:04:37 +0100 Subject: [PATCH] Provide a proper error when the provided port is not an integer As reported on the mailinglist, the user received a ValueError when the port number was not templated (fixed in #1649) and therefore it was not an integer. This change will catch the exception and provide a proper error so it is more clear. --- lib/ansible/runner/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/ansible/runner/__init__.py b/lib/ansible/runner/__init__.py index 45a6d3e9c4e..4fda5b2be68 100644 --- a/lib/ansible/runner/__init__.py +++ b/lib/ansible/runner/__init__.py @@ -382,6 +382,11 @@ class Runner(object): try: if actual_port is not None: actual_port = int(actual_port) + except ValueError, e: + result = dict(failed=True, msg="FAILED: Configured port \"%s\" is not a valid port, expected integer" % actual_port) + return ReturnData(host=host, comm_ok=False, result=result) + + try: conn = self.connector.connect(actual_host, actual_port) if delegate_to or host != actual_host: conn.delegate = host