get_url and preemptive authentication?

Hello,

we provide user specific settings for our Maven repository via a HTTP
GET request[1], but have the usecase that "anonymous" has read-only
access, so authentication is not strictly enforced.

I try to setup our CI system with ansible coming from a shell based
setup, where I have:

curl --netrc -o ~/.m2/settings.xml http://repo/path/settings.xml

Now, curl sends the basic auth header in any case, while get_url[2]
waits for a 401 to come back before offering credentials. So with
get_url the credentials are not used but the settings.xml for
anonymous are downloaded.

I could implement a PR with an option to send authentication
preemptively and default to the current behavior.

On the other hand I think anyone using get_url with url_password knows
that authentication is needed, so IMO sending the auth-header directly
by default would be more useful and the current behavior only produces
the overhead of additional requests.

Regards Mirko
[1] we use Artifactory templating here.
[2] inspecting ansible/module_utils/urls.py

You might be interested in https://github.com/ansible/ansible-modules-core/pull/153

Hello Matt,

thanks, any chances that this will make it into version 1.8?
Regards Mirko

1.8 is releasing soon so this is unlikely.

It is prioritized p3 so it’s next in line though.

You can use your own version of get_url by dropping in “./library” relative to your playbook, which would allow you to use this today.

Thanks, good to know :slight_smile:

Regards
Mirko