uri.py is not using module_utils/urls.py from ansible core
This commit is contained in:
parent
3d3be5e91f
commit
d6fc0ac5be
1 changed files with 10 additions and 0 deletions
|
@ -23,6 +23,7 @@
|
||||||
import cgi
|
import cgi
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
|
import base64
|
||||||
import datetime
|
import datetime
|
||||||
try:
|
try:
|
||||||
import json
|
import json
|
||||||
|
@ -367,6 +368,7 @@ def main():
|
||||||
body_format = dict(required=False, default='raw', choices=['raw', 'json']),
|
body_format = dict(required=False, default='raw', choices=['raw', 'json']),
|
||||||
method = dict(required=False, default='GET', choices=['GET', 'POST', 'PUT', 'HEAD', 'DELETE', 'OPTIONS', 'PATCH', 'TRACE', 'CONNECT', 'REFRESH']),
|
method = dict(required=False, default='GET', choices=['GET', 'POST', 'PUT', 'HEAD', 'DELETE', 'OPTIONS', 'PATCH', 'TRACE', 'CONNECT', 'REFRESH']),
|
||||||
return_content = dict(required=False, default='no', type='bool'),
|
return_content = dict(required=False, default='no', type='bool'),
|
||||||
|
force_basic_auth = dict(required=False, default='no', type='bool'),
|
||||||
follow_redirects = dict(required=False, default='safe', choices=['all', 'safe', 'none', 'yes', 'no']),
|
follow_redirects = dict(required=False, default='safe', choices=['all', 'safe', 'none', 'yes', 'no']),
|
||||||
creates = dict(required=False, default=None),
|
creates = dict(required=False, default=None),
|
||||||
removes = dict(required=False, default=None),
|
removes = dict(required=False, default=None),
|
||||||
|
@ -391,6 +393,7 @@ def main():
|
||||||
method = module.params['method']
|
method = module.params['method']
|
||||||
dest = module.params['dest']
|
dest = module.params['dest']
|
||||||
return_content = module.params['return_content']
|
return_content = module.params['return_content']
|
||||||
|
force_basic_auth = module.params['force_basic_auth']
|
||||||
redirects = module.params['follow_redirects']
|
redirects = module.params['follow_redirects']
|
||||||
creates = module.params['creates']
|
creates = module.params['creates']
|
||||||
removes = module.params['removes']
|
removes = module.params['removes']
|
||||||
|
@ -430,6 +433,13 @@ def main():
|
||||||
module.exit_json(stdout="skipped, since %s does not exist" % removes, changed=False, stderr=False, rc=0)
|
module.exit_json(stdout="skipped, since %s does not exist" % removes, changed=False, stderr=False, rc=0)
|
||||||
|
|
||||||
|
|
||||||
|
# httplib2 only sends authentication after the server asks for it with a 401.
|
||||||
|
# Some 'basic auth' servies fail to send a 401 and require the authentication
|
||||||
|
# up front. This creates the Basic authentication header and sends it immediately.
|
||||||
|
if force_basic_auth:
|
||||||
|
dict_headers["Authorization"] = "Basic {0}".format(base64.b64encode("{0}:{1}".format(user, password)))
|
||||||
|
|
||||||
|
|
||||||
# Make the request
|
# Make the request
|
||||||
resp, content, dest = uri(module, url, dest, user, password, body, body_format, method, dict_headers, redirects, socket_timeout, validate_certs)
|
resp, content, dest = uri(module, url, dest, user, password, body, body_format, method, dict_headers, redirects, socket_timeout, validate_certs)
|
||||||
resp['status'] = int(resp['status'])
|
resp['status'] = int(resp['status'])
|
||||||
|
|
Loading…
Reference in a new issue