From 063f5d0ca8a326172f0981d28021e5c9fb7f42b4 Mon Sep 17 00:00:00 2001 From: Andreas Olsson Date: Thu, 20 Jul 2017 21:34:41 +0200 Subject: [PATCH] Set default user-agent for module_utils.urls fetch_url (#27095) The HTTP User-Agent "ansible-httpget" is already kind of the default, it being the default value provided by the `url_argument_spec` helper method. Yet, it may not be practical for all modules to get their argument_spec that way. Without a default User-Agent we fall back on the library User-Agent. That being something like "Python-urllib/2.7". While I'm no big fan of web servers making decisions based on the provided User-Agent I still think that part of being a well-behaved HTTP client is to provide an informative User-Agent. Not to mention that it's a good thing for Ansible to behave consistently. Indirectly fixes #26239 --- lib/ansible/module_utils/urls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/module_utils/urls.py b/lib/ansible/module_utils/urls.py index ff5b84e42c7..661e4bb159e 100644 --- a/lib/ansible/module_utils/urls.py +++ b/lib/ansible/module_utils/urls.py @@ -1020,7 +1020,7 @@ def fetch_url(module, url, data=None, headers=None, method=None, username = module.params.get('url_username', '') password = module.params.get('url_password', '') - http_agent = module.params.get('http_agent', None) + http_agent = module.params.get('http_agent', 'ansible-httpget') force_basic_auth = module.params.get('force_basic_auth', '') follow_redirects = module.params.get('follow_redirects', 'urllib2')