From 73abde399cbeb6d67592ff649e9fe415fa82845d Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde Date: Tue, 12 Dec 2017 22:02:36 +0530 Subject: [PATCH] VMware: Fix SSL Context checking for Python <2.7.9 (#33683) Fixes: #33602 Signed-off-by: Abhijeet Kasurde --- lib/ansible/module_utils/vmware.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/module_utils/vmware.py b/lib/ansible/module_utils/vmware.py index 074b6aa23f..9241cd7d54 100644 --- a/lib/ansible/module_utils/vmware.py +++ b/lib/ansible/module_utils/vmware.py @@ -449,10 +449,10 @@ def connect_to_api(module, disconnect_atexit=True): if validate_certs and not hasattr(ssl, 'SSLContext'): module.fail_json(msg='pyVim does not support changing verification mode with python < 2.7.9. Either update ' - 'python or or use validate_certs=false') + 'python or use validate_certs=false.') ssl_context = None - if not validate_certs: + if not validate_certs and hasattr(ssl, 'SSLContext'): ssl_context = ssl.SSLContext(ssl.PROTOCOL_SSLv23) ssl_context.verify_mode = ssl.CERT_NONE