Fix urllib based on python version and add better error handling in ansible logs
What does this PR do?
What's changed? Why were these changes made?
How should the reviewer approach this PR, especially if manual tests are required?
Are there relevant screenshots you can add to the PR description?
Added urllib fix that works based on the python environment you are in. urllib.quote will be used for python2 and urllib.parse.quite will be used for python3.
Added more visible error handling on what exactly was the problem in debug mode (ansible-playbook -vvv) on CyberArk. ("error_body_message" dict and error message in "msg")
New result:
fatal: [localhost]: FAILED! => {
"changed": false,
"error_body_message": {
"ErrorCode": "APPAP306E",
"ErrorMsg": "Authentication error for App ID [XXXX]. Reason: APPAP133E Failed to verify application authentication data: IP \"123.456.789.000\" is unauthorized"
},
"invocation": {
"module_args": {
"api_base_url": "TSPAM_URL",
"app_id": "XXXX",
"client_cert": null,
"client_key": null,
"connection_timeout": 30,
"fail_request_on_password_change": false,
"query": "Safe=safe;username=root;address=123.456.789.321",
"query_format": "Exact",
"reason": null,
"state": "present",
"validate_certs": false
}
},
"msg": "Error while retrieving credential.Please validate parameters provided, and permissions for the application and provider in CyberArk.\n*** end_point=TSPAM_URL/AIMWebService/api/Accounts?AppId=XXXX&Query=Safe%3Dsafe%3Busername%3Droot%3Baddress%3D123.456.789.321&ConnectionTimeout=30&QueryFormat=Exact&FailRequestOnPasswordChange=False\n ==> HTTP Error 403: Forbidden.\nBody error message: Authentication error for App ID [XXXX]. Reason: APPAP133E Failed to verify application authentication data: IP \"123.456.789.000\" is unauthorized",
"status_code": 403
}
What ticket does this PR close?
Resolves #[relevant GitHub issues, eg 76]
Checklists
Change log
[ ] The CHANGELOG has been updated, or
[x] This PR does not include user-facing changes and doesn't require a CHANGELOG update
Test coverage
[ ] This PR includes new unit and integration tests to go with the code changes, or
[x] The changes in this PR do not require tests
Documentation
[ ] Docs (e.g. READMEs) were updated in this PR, and/or there is a follow-on issue to update docs, or
[x] This PR does not require updating any documentation
Fix urllib based on python version and add better error handling in ansible logs
What does this PR do?
Added urllib fix that works based on the python environment you are in. urllib.quote will be used for python2 and urllib.parse.quite will be used for python3.
Added more visible error handling on what exactly was the problem in debug mode (ansible-playbook -vvv) on CyberArk. ("error_body_message" dict and error message in "msg")
New result:
What ticket does this PR close?
Resolves #[relevant GitHub issues, eg 76]
Checklists
Change log
Test coverage
Documentation
README
s) were updated in this PR, and/or there is a follow-on issue to update docs, or