Bubble up import exception content for k8s module (#50657)

* Bubble up import exception content for k8s module

Signed-off-by: Fabian von Feilitzsch <fabian@fabianism.us>

* Track down other places import exception is reported

* Add changelog fragment
This commit is contained in:
Fabian von Feilitzsch 2019-01-14 19:44:59 -05:00 committed by Will Thames
commit 09bfe42a5c
4 changed files with 13 additions and 6 deletions

View file

@ -32,8 +32,10 @@ try:
from openshift.dynamic import DynamicClient
from openshift.dynamic.exceptions import ResourceNotFoundError, ResourceNotUniqueError
HAS_K8S_MODULE_HELPER = True
except ImportError:
k8s_import_exception = None
except ImportError as e:
HAS_K8S_MODULE_HELPER = False
k8s_import_exception = e
try:
import yaml
@ -242,7 +244,7 @@ class KubernetesAnsibleModule(AnsibleModule, K8sAnsibleMixin):
AnsibleModule.__init__(self, *args, **kwargs)
if not HAS_K8S_MODULE_HELPER:
self.fail_json(msg="This module requires the OpenShift Python client. Try `pip install openshift`")
self.fail_json(msg="This module requires the OpenShift Python client. Try `pip install openshift`", error=str(k8s_import_exception))
self.openshift_version = openshift.__version__
if not HAS_YAML: