diff --git a/lib/ansible/module_utils/known_hosts.py b/lib/ansible/module_utils/known_hosts.py index 522b34302a..ecfdf639fe 100644 --- a/lib/ansible/module_utils/known_hosts.py +++ b/lib/ansible/module_utils/known_hosts.py @@ -27,6 +27,7 @@ # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. import hmac +import urlparse try: from hashlib import sha1 @@ -56,7 +57,8 @@ def get_fqdn(repo_url): """ chop the hostname out of a giturl """ result = None - if "@" in repo_url and not repo_url.startswith("http"): + if "@" in repo_url and "://" not in repo_url: + # most likely a git@ or ssh+git@ type URL repo_url = repo_url.split("@", 1)[1] if ":" in repo_url: repo_url = repo_url.split(":")[0] @@ -64,6 +66,11 @@ def get_fqdn(repo_url): elif "/" in repo_url: repo_url = repo_url.split("/")[0] result = repo_url + elif "://" in repo_url: + # this should be something we can parse with urlparse + parts = urlparse.urlparse(repo_url) + if parts[1] != '': + result = parts[1] return result