diff --git a/lib/ansible/module_utils/vmware.py b/lib/ansible/module_utils/vmware.py index a7b9a7b0355..1970b944316 100644 --- a/lib/ansible/module_utils/vmware.py +++ b/lib/ansible/module_utils/vmware.py @@ -15,6 +15,11 @@ from random import randint try: # requests is required for exception handling of the ConnectionError import requests + HAS_REQUESTS = True +except ImportError: + HAS_REQUESTS = False + +try: from pyVim import connect from pyVmomi import vim, vmodl HAS_PYVMOMI = True @@ -777,6 +782,10 @@ class PyVmomi(object): """ Constructor """ + if not HAS_REQUESTS: + self.module.fail_json(msg="Unable to find 'requests' Python library which is required." + " Please install using 'pip install requests'") + if not HAS_PYVMOMI: module.fail_json(msg='PyVmomi Python module required. Install using "pip install PyVmomi"')