mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-26 04:11:25 -07:00
Add helper function to return helpful import error msg (#47409)
This commit is contained in:
parent
f28b7c7ab1
commit
ddfd1dbfc6
3 changed files with 22 additions and 15 deletions
|
@ -321,10 +321,9 @@ rc:
|
|||
sample: 0
|
||||
'''
|
||||
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
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, to_text
|
||||
|
||||
PYPSEXEC_IMP_ERR = None
|
||||
|
@ -407,9 +406,7 @@ def main():
|
|||
'running as System: process_username, '
|
||||
'process_password')
|
||||
if not HAS_PYPSEXEC:
|
||||
module.fail_json(msg="The pypsexec Python module is required to be "
|
||||
"installed for the Python environment at '%s'"
|
||||
% sys.executable,
|
||||
module.fail_json(msg=missing_required_lib("pypsexec"),
|
||||
exception=PYPSEXEC_IMP_ERR)
|
||||
|
||||
hostname = module.params['hostname']
|
||||
|
@ -443,11 +440,8 @@ def main():
|
|||
|
||||
if connection_username is None or connection_password is None and \
|
||||
not HAS_KERBEROS:
|
||||
module.fail_json(msg="The gssapi Python module with the GGF extension "
|
||||
"used for kerberos auth is required to be "
|
||||
"installed for the Python environment at '%s'"
|
||||
% sys.executable,
|
||||
exception=KERBEROS_IMP_ERR)
|
||||
module.fail_json(msg=missing_required_lib("gssapi"),
|
||||
execption=KERBEROS_IMP_ERR)
|
||||
|
||||
win_client = client.Client(server=hostname, username=connection_username,
|
||||
password=connection_password, port=port,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue