mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 20:01: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
|
@ -86,15 +86,18 @@ RETURN = '''
|
|||
'''
|
||||
|
||||
import os
|
||||
import traceback
|
||||
|
||||
PYMSSQL_IMP_ERR = None
|
||||
try:
|
||||
import pymssql
|
||||
except ImportError:
|
||||
PYMSSQL_IMP_ERR = traceback.format_exc()
|
||||
mssql_found = False
|
||||
else:
|
||||
mssql_found = True
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||
|
||||
|
||||
def db_exists(conn, cursor, db):
|
||||
|
@ -155,7 +158,7 @@ def main():
|
|||
)
|
||||
|
||||
if not mssql_found:
|
||||
module.fail_json(msg="pymssql python module is required")
|
||||
module.fail_json(msg=missing_required_lib('pymssql'), exception=PYMSSQL_IMP_ERR)
|
||||
|
||||
db = module.params['name']
|
||||
state = module.params['state']
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue