|
|
|
@ -127,6 +127,7 @@ except ImportError:
|
|
|
|
|
# python3
|
|
|
|
|
from urllib.parse import urlencode
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def is_csrf_protection_enabled(module):
|
|
|
|
|
resp, info = fetch_url(module,
|
|
|
|
|
module.params['url'] + '/api/json',
|
|
|
|
@ -137,6 +138,7 @@ def is_csrf_protection_enabled(module):
|
|
|
|
|
content = resp.read()
|
|
|
|
|
return json.loads(content).get('useCrumbs', False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_crumb(module):
|
|
|
|
|
resp, info = fetch_url(module,
|
|
|
|
|
module.params['url'] + '/crumbIssuer/api/json',
|
|
|
|
@ -147,6 +149,7 @@ def get_crumb(module):
|
|
|
|
|
content = resp.read()
|
|
|
|
|
return json.loads(content)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
|
|
|
|
|
module = AnsibleModule(
|
|
|
|
@ -160,7 +163,6 @@ def main():
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if module.params['user'] is not None:
|
|
|
|
|
if module.params['password'] is None:
|
|
|
|
|
module.fail_json(msg="password required when user provided")
|
|
|
|
@ -168,7 +170,6 @@ def main():
|
|
|
|
|
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'])
|
|
|
|
@ -199,6 +200,5 @@ def main():
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
main()
|
|
|
|
|