From c55187ff42eb9211da3a04ed5e079e774e365cac Mon Sep 17 00:00:00 2001 From: Andrey Trubachev Date: Sat, 3 Jan 2015 10:32:27 +0300 Subject: [PATCH] Fix 'wait_for' doesn't work with ipv6only host --- lib/ansible/modules/utilities/logic/wait_for.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/ansible/modules/utilities/logic/wait_for.py b/lib/ansible/modules/utilities/logic/wait_for.py index 95653b56d3e..aa6bd1050c4 100644 --- a/lib/ansible/modules/utilities/logic/wait_for.py +++ b/lib/ansible/modules/utilities/logic/wait_for.py @@ -362,10 +362,8 @@ def main(): except IOError: break elif port: - s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - s.settimeout(connect_timeout) try: - s.connect( (host, port) ) + s = socket.create_connection( (host, port), connect_timeout) s.shutdown(socket.SHUT_RDWR) s.close() time.sleep(1) @@ -410,10 +408,8 @@ def main(): elapsed = datetime.datetime.now() - start module.fail_json(msg="Failed to stat %s, %s" % (path, e.strerror), elapsed=elapsed.seconds) elif port: - s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - s.settimeout(connect_timeout) try: - s.connect( (host, port) ) + s = socket.create_connection( (host, port), connect_timeout) if search_regex: data = '' matched = False