mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 03:41:25 -07:00
Add check for requests module
Fix adds check for requests Python module and suggests user to install, if no requests module installation found. Fixes: #27643 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
parent
31b4ae2e6a
commit
748fa5db35
3 changed files with 25 additions and 3 deletions
|
@ -105,7 +105,11 @@ EXAMPLES = '''
|
|||
'''
|
||||
|
||||
import json
|
||||
import requests
|
||||
try:
|
||||
import requests
|
||||
HAS_REQUESTS = True
|
||||
except ImportError as e:
|
||||
HAS_REQUESTS = False
|
||||
import urllib
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
@ -137,6 +141,9 @@ def main():
|
|||
urllib.quote(module.params['name'],'')
|
||||
)
|
||||
|
||||
if not HAS_REQUESTS:
|
||||
module.fail_json(msg="requests library is required for this module. To install, use `pip install requests`")
|
||||
|
||||
# Check if exchange already exists
|
||||
r = requests.get( url, auth=(module.params['login_user'],module.params['login_password']))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue