From 4331fcae3436543d4f22fd920c026ae1df2f262f Mon Sep 17 00:00:00 2001 From: callipeo Date: Tue, 9 Feb 2016 19:51:16 +0100 Subject: [PATCH] Add support for both keyserver and keyring in apt_key Fixes Issue #2996 --- lib/ansible/modules/packaging/os/apt_key.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/packaging/os/apt_key.py b/lib/ansible/modules/packaging/os/apt_key.py index bedd159f0c9..bc8cb80b5c8 100644 --- a/lib/ansible/modules/packaging/os/apt_key.py +++ b/lib/ansible/modules/packaging/os/apt_key.py @@ -166,8 +166,11 @@ def download_key(module, url): except Exception: module.fail_json(msg="error getting key id from url: %s" % url, traceback=format_exc()) -def import_key(module, keyserver, key_id): - cmd = "apt-key adv --keyserver %s --recv %s" % (keyserver, key_id) +def import_key(module, keyring, keyserver, key_id): + if keyring: + cmd = "apt-key --keyring %s adv --keyserver %s --recv %s" % (keyring, keyserver, key_id) + else: + cmd = "apt-key adv --keyserver %s --recv %s" % (keyserver, key_id) (rc, out, err) = module.run_command(cmd, check_rc=True) return True @@ -253,7 +256,7 @@ def main(): if filename: add_key(module, filename, keyring) elif keyserver: - import_key(module, keyserver, key_id) + import_key(module, keyring, keyserver, key_id) else: add_key(module, "-", keyring, data) changed=False