@ -21,6 +21,12 @@ from ansible.module_utils.urls import open_url
from ansible . utils . display import Display
from ansible . utils . display import Display
from ansible . utils . hashing import secure_hash_s
from ansible . utils . hashing import secure_hash_s
try :
from urllib . parse import urlparse
except ImportError :
# Python 2
from urlparse import urlparse
display = Display ( )
display = Display ( )
@ -289,13 +295,19 @@ class GalaxyAPI:
data = self . _call_galaxy ( url )
data = self . _call_galaxy ( url )
results = data [ ' results ' ]
results = data [ ' results ' ]
done = ( data . get ( ' next_link ' , None ) is None )
done = ( data . get ( ' next_link ' , None ) is None )
# https://github.com/ansible/ansible/issues/64355
# api_server contains part of the API path but next_link includes the the /api part so strip it out.
url_info = urlparse ( self . api_server )
base_url = " %s :// %s / " % ( url_info . scheme , url_info . netloc )
while not done :
while not done :
url = _urljoin ( self . api_server , data [ ' next_link ' ] )
url = _urljoin ( base_url , data [ ' next_link ' ] )
data = self . _call_galaxy ( url )
data = self . _call_galaxy ( url )
results + = data [ ' results ' ]
results + = data [ ' results ' ]
done = ( data . get ( ' next_link ' , None ) is None )
done = ( data . get ( ' next_link ' , None ) is None )
except Exception as e :
except Exception as e :
display . vvvv ( " Unable to retri ve role (id=%s ) data ( %s ), but this is not fatal so we continue: %s "
display . warning ( " Unable to retri e ve role (id=%s ) data ( %s ), but this is not fatal so we continue: %s "
% ( role_id , related , to_text ( e ) ) )
% ( role_id , related , to_text ( e ) ) )
return results
return results