From 8a49dac5d11dbc25d9df9fbc30f76c79e83ff63f Mon Sep 17 00:00:00 2001 From: lessmian Date: Mon, 18 Feb 2013 17:03:50 +0100 Subject: [PATCH] Fixed remove_key --- library/apt_key | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/library/apt_key b/library/apt_key index 7bc9287eab1..35452ae7a4c 100644 --- a/library/apt_key +++ b/library/apt_key @@ -115,9 +115,9 @@ def add_key(module, key): (rc, out, err) = module.run_command(cmd, data=key, check_rc=True) return True -def remove_key(key_id): +def remove_key(module, key_id): # FIXME: use module.run_command, fail at point of error and don't discard useful stdin/stdout - cmd = 'apt-key del %s' + cmd = 'apt-key del %s' % key_id (rc, out, err) = module.run_command(cmd, check_rc=True) return True @@ -142,6 +142,7 @@ def main(): check_missing_binaries(module) keys = all_keys(module) + return_values = {} if state == 'present': if key_id and key_id in keys: @@ -164,13 +165,13 @@ def main(): if not key_id: module.fail_json(msg="key is required") if key_id in keys: - if remove_key(key_id): + if remove_key(module, key_id): changed=True else: # FIXME: module.fail_json or exit-json immediately at point of failure - module.fail_json(msg="error removing key_id", **return_values(True)) + module.fail_json(msg="error removing key_id", **return_values) - module.exit_json(changed=changed, **return_values()) + module.exit_json(changed=changed, **return_values) # include magic from lib/ansible/module_common.py #<>