From 779e6e3864ccfa1a49b453318a20c9557b83d965 Mon Sep 17 00:00:00 2001 From: Bertrand Lanson Date: Wed, 27 Dec 2023 13:40:25 +0100 Subject: [PATCH] feat(modules): try catch on import --- plugins/modules/vault_init.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plugins/modules/vault_init.py b/plugins/modules/vault_init.py index b933e8c..2d16358 100644 --- a/plugins/modules/vault_init.py +++ b/plugins/modules/vault_init.py @@ -68,7 +68,15 @@ message: ''' from ansible.module_utils.basic import AnsibleModule -import hvac + +try: + import hvac +except ImportError: + HAS_HVAC = False + HVAC_IMPORT_ERROR = traceback.format_exc() +else: + HVAC_IMPORT_ERROR = None + HAS_HVAC = True def run_module(): # define available arguments/parameters a user can pass to the module