|
|
|
@ -115,7 +115,7 @@ def is_csrf_protection_enabled(module):
|
|
|
|
|
module.params['url'] + '/api/json',
|
|
|
|
|
method='GET')
|
|
|
|
|
if info["status"] != 200:
|
|
|
|
|
module.fail_json(msg="HTTP error " + str(info["status"]) + " " + info["msg"])
|
|
|
|
|
module.fail_json(msg="HTTP error " + str(info["status"]) + " " + info["msg"], output='')
|
|
|
|
|
|
|
|
|
|
content = to_native(resp.read())
|
|
|
|
|
return json.loads(content).get('useCrumbs', False)
|
|
|
|
@ -126,7 +126,7 @@ def get_crumb(module):
|
|
|
|
|
module.params['url'] + '/crumbIssuer/api/json',
|
|
|
|
|
method='GET')
|
|
|
|
|
if info["status"] != 200:
|
|
|
|
|
module.fail_json(msg="HTTP error " + str(info["status"]) + " " + info["msg"])
|
|
|
|
|
module.fail_json(msg="HTTP error " + str(info["status"]) + " " + info["msg"], output='')
|
|
|
|
|
|
|
|
|
|
content = to_native(resp.read())
|
|
|
|
|
return json.loads(content)
|
|
|
|
@ -148,14 +148,17 @@ def main():
|
|
|
|
|
|
|
|
|
|
if module.params['user'] is not None:
|
|
|
|
|
if module.params['password'] is None:
|
|
|
|
|
module.fail_json(msg="password required when user provided")
|
|
|
|
|
module.fail_json(msg="password required when user provided", output='')
|
|
|
|
|
module.params['url_username'] = module.params['user']
|
|
|
|
|
module.params['url_password'] = module.params['password']
|
|
|
|
|
module.params['force_basic_auth'] = True
|
|
|
|
|
|
|
|
|
|
if module.params['args'] is not None:
|
|
|
|
|
from string import Template
|
|
|
|
|
script_contents = Template(module.params['script']).substitute(module.params['args'])
|
|
|
|
|
try:
|
|
|
|
|
script_contents = Template(module.params['script']).substitute(module.params['args'])
|
|
|
|
|
except KeyError as err:
|
|
|
|
|
module.fail_json(msg="Error with templating variable: %s" % err, output='')
|
|
|
|
|
else:
|
|
|
|
|
script_contents = module.params['script']
|
|
|
|
|
|
|
|
|
@ -172,12 +175,12 @@ def main():
|
|
|
|
|
timeout=module.params['timeout'])
|
|
|
|
|
|
|
|
|
|
if info["status"] != 200:
|
|
|
|
|
module.fail_json(msg="HTTP error " + str(info["status"]) + " " + info["msg"])
|
|
|
|
|
module.fail_json(msg="HTTP error " + str(info["status"]) + " " + info["msg"], output='')
|
|
|
|
|
|
|
|
|
|
result = to_native(resp.read())
|
|
|
|
|
|
|
|
|
|
if 'Exception:' in result and 'at java.lang.Thread' in result:
|
|
|
|
|
module.fail_json(msg="script failed with stacktrace:\n " + result)
|
|
|
|
|
module.fail_json(msg="script failed with stacktrace:\n " + result, output='')
|
|
|
|
|
|
|
|
|
|
module.exit_json(
|
|
|
|
|
output=result,
|
|
|
|
|