mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-26 20:31:27 -07:00
start getting modules to use shared import error code (#51787)
This commit is contained in:
parent
0924a8cf67
commit
0f0d33a954
46 changed files with 230 additions and 108 deletions
|
@ -95,15 +95,18 @@ EXAMPLES = """
|
|||
"""
|
||||
|
||||
import time
|
||||
import traceback
|
||||
|
||||
KAZOO_IMP_ERR = None
|
||||
try:
|
||||
from kazoo.client import KazooClient
|
||||
from kazoo.handlers.threading import KazooTimeoutError
|
||||
KAZOO_INSTALLED = True
|
||||
except ImportError:
|
||||
KAZOO_IMP_ERR = traceback.format_exc()
|
||||
KAZOO_INSTALLED = False
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||
from ansible.module_utils._text import to_bytes
|
||||
|
||||
|
||||
|
@ -122,7 +125,7 @@ def main():
|
|||
)
|
||||
|
||||
if not KAZOO_INSTALLED:
|
||||
module.fail_json(msg='kazoo >= 2.1 is required to use this module. Use pip to install it.')
|
||||
module.fail_json(msg=missing_required_lib('kazoo >= 2.1'), exception=KAZOO_IMP_ERR)
|
||||
|
||||
check = check_params(module.params)
|
||||
if not check['success']:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue