parent
3a20291838
commit
89fa9b7305
3 changed files with 32 additions and 9 deletions
|
@ -69,6 +69,8 @@ Other notable changes:
|
||||||
* regex_replace filter plugin added
|
* regex_replace filter plugin added
|
||||||
* added an inventory script for Docker
|
* added an inventory script for Docker
|
||||||
* added an inventory script for Abiquo
|
* added an inventory script for Abiquo
|
||||||
|
* the get_url module now accepts url_username and url_password as parameters, so sites which require
|
||||||
|
authentication no longer need to have them embedded in the url
|
||||||
* ... to be filled in from changelogs ...
|
* ... to be filled in from changelogs ...
|
||||||
*
|
*
|
||||||
|
|
||||||
|
|
|
@ -200,6 +200,8 @@ def url_argument_spec():
|
||||||
http_agent = dict(default='ansible-httpget'),
|
http_agent = dict(default='ansible-httpget'),
|
||||||
use_proxy = dict(default='yes', type='bool'),
|
use_proxy = dict(default='yes', type='bool'),
|
||||||
validate_certs = dict(default='yes', type='bool'),
|
validate_certs = dict(default='yes', type='bool'),
|
||||||
|
url_username = dict(required=False),
|
||||||
|
url_password = dict(required=False),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -247,15 +249,22 @@ def fetch_url(module, url, data=None, headers=None, method=None,
|
||||||
ssl_handler = SSLValidationHandler(module, hostname, port)
|
ssl_handler = SSLValidationHandler(module, hostname, port)
|
||||||
handlers.append(ssl_handler)
|
handlers.append(ssl_handler)
|
||||||
|
|
||||||
if parsed[0] != 'ftp' and '@' in parsed[1]:
|
if parsed[0] != 'ftp':
|
||||||
credentials, netloc = parsed[1].split('@', 1)
|
url_username = module.params.get('url_username', '')
|
||||||
if ':' in credentials:
|
if url_username:
|
||||||
username, password = credentials.split(':', 1)
|
username = url_username
|
||||||
else:
|
password = module.params.get('url_password', '')
|
||||||
username = credentials
|
netloc = parsed[1]
|
||||||
password = ''
|
elif '@' in parsed[1]:
|
||||||
parsed = list(parsed)
|
credentials, netloc = parsed[1].split('@', 1)
|
||||||
parsed[1] = netloc
|
if ':' in credentials:
|
||||||
|
username, password = credentials.split(':', 1)
|
||||||
|
else:
|
||||||
|
username = credentials
|
||||||
|
password = ''
|
||||||
|
|
||||||
|
parsed = list(parsed)
|
||||||
|
parsed[1] = netloc
|
||||||
|
|
||||||
passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
|
passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
|
||||||
# this creates a password manager
|
# this creates a password manager
|
||||||
|
|
|
@ -90,6 +90,18 @@ options:
|
||||||
required: false
|
required: false
|
||||||
default: 'yes'
|
default: 'yes'
|
||||||
choices: ['yes', 'no']
|
choices: ['yes', 'no']
|
||||||
|
url_username:
|
||||||
|
description:
|
||||||
|
- The username for use in HTTP basic authentication. This parameter can be used
|
||||||
|
without C(url_password) for sites that allow empty passwords.
|
||||||
|
required: false
|
||||||
|
version_added: '1.6'
|
||||||
|
url_password:
|
||||||
|
description:
|
||||||
|
- The password for use in HTTP basic authentication. If the C(url_username)
|
||||||
|
parameter is not specified, the C(url_password) parameter will not be used.
|
||||||
|
required: false
|
||||||
|
version_added: '1.6'
|
||||||
others:
|
others:
|
||||||
description:
|
description:
|
||||||
- all arguments accepted by the M(file) module also work here
|
- all arguments accepted by the M(file) module also work here
|
||||||
|
|
Loading…
Reference in a new issue