diff options
author | Michael Schuett <schuettm@uberatc.com> | 2016-10-31 12:19:22 -0400 |
---|---|---|
committer | Brian Coca <brian.coca+git@gmail.com> | 2016-11-23 14:39:37 -0500 |
commit | f4a2332d4890634e4a285dc7fb89373c33f10b00 (patch) | |
tree | b67ffd1beb48860e9db098649ce4401aad6f409f | |
parent | a60a7279d03ad736e4fbf8ae8e7b12420ad783a1 (diff) | |
download | ansible-f4a2332d4890634e4a285dc7fb89373c33f10b00.tar.gz |
Fix auth in collins.py inventory
This forces basic auth to be used. Using the normal HTTPPasswordMgrWithDefaultRealm
password manager from urllib2 fails since collins doesn't send a 401 retry on failure.
More about this can be seen here http://stackoverflow.com/questions/2407126/python-urllib2-basic-auth-problem.
I added a small comment about the format of the host so others don't waste time like i did.
(cherry picked from commit 21813ed83eb899a7c2c78b024abcd9db6ce01023)
-rw-r--r-- | contrib/inventory/collins.ini | 2 | ||||
-rwxr-xr-x | contrib/inventory/collins.py | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/contrib/inventory/collins.ini b/contrib/inventory/collins.ini index 748fcf854a..0ce0c2acbd 100644 --- a/contrib/inventory/collins.ini +++ b/contrib/inventory/collins.ini @@ -3,6 +3,8 @@ [collins] +# You should not have a trailing slash or collins +# will not properly match the URI host = http://localhost:9000 username = blake diff --git a/contrib/inventory/collins.py b/contrib/inventory/collins.py index bbcb32b017..b7193e2f8f 100755 --- a/contrib/inventory/collins.py +++ b/contrib/inventory/collins.py @@ -201,7 +201,8 @@ class CollinsInventory(object): response = open_url(query_url, timeout=self.collins_timeout_secs, url_username=self.collins_username, - url_password=self.collins_password) + url_password=self.collins_password, + force_basic_auth=True) json_response = json.loads(response.read()) # Adds any assets found to the array of assets. assets += json_response['data']['Data'] |