mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-16 01:45:25 -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
|
@ -74,14 +74,16 @@ EXAMPLES = """
|
|||
"""
|
||||
import traceback
|
||||
|
||||
PYODBC_IMP_ERR = None
|
||||
try:
|
||||
import pyodbc
|
||||
except ImportError:
|
||||
PYODBC_IMP_ERR = traceback.format_exc()
|
||||
pyodbc_found = False
|
||||
else:
|
||||
pyodbc_found = True
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||
from ansible.module_utils._text import to_native
|
||||
|
||||
|
||||
|
@ -180,7 +182,7 @@ def main():
|
|||
), supports_check_mode=True)
|
||||
|
||||
if not pyodbc_found:
|
||||
module.fail_json(msg="The python pyodbc module is required.")
|
||||
module.fail_json(msg=missing_required_lib('pyodbc'), exception=PYODBC_IMP_ERR)
|
||||
|
||||
role = module.params['role']
|
||||
assigned_roles = []
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue