Fixed misleading helm module import failure message (#44916)

This commit is contained in:
Tristan Sweeney 2019-12-11 04:34:42 -05:00 committed by Abhijeet Kasurde
parent 19220a0607
commit 4da87fb3ee

View file

@ -104,15 +104,16 @@ EXAMPLES = '''
namespace: default namespace: default
''' '''
import traceback
HELM_IMPORT_ERR = None
try: try:
import grpc import grpc
from pyhelm import tiller from pyhelm import tiller
from pyhelm import chartbuilder from pyhelm import chartbuilder
HAS_PYHELM = True except ImportError:
except ImportError as exc: HELM_IMPORT_ERR = traceback.format_exc()
HAS_PYHELM = False
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule, missing_required_lib
def install(module, tserver): def install(module, tserver):
@ -182,9 +183,8 @@ def main():
), ),
supports_check_mode=True) supports_check_mode=True)
if not HAS_PYHELM: if HELM_IMPORT_ERR:
module.fail_json(msg="Could not import the pyhelm python module. " module.fail_json(msg=missing_required_lib('pyhelm'), exception=HELM_IMPORT_ERR)
"Please install `pyhelm` package.")
host = module.params['host'] host = module.params['host']
port = module.params['port'] port = module.params['port']