From dfc625a7df1a903969345b21321966ebdef2dce0 Mon Sep 17 00:00:00 2001 From: trbs Date: Wed, 25 Jun 2014 15:30:34 +0200 Subject: [PATCH] apt_key clear message when downloading key returns an (http) error code --- library/packaging/apt_key | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/packaging/apt_key b/library/packaging/apt_key index 55eb9b1948..7c1ba2e265 100644 --- a/library/packaging/apt_key +++ b/library/packaging/apt_key @@ -153,8 +153,12 @@ def download_key(module, url): # and reuse here if url is None: module.fail_json(msg="needed a URL but was not specified") + try: rsp, info = fetch_url(module, url) + if info['status'] != 200: + module.fail_json(msg="Failed to download key at %s: %s" % (url, info['msg'])) + return rsp.read() except Exception: module.fail_json(msg="error getting key id from url: %s" % url, traceback=format_exc())