From caddf863df3acac5adadba35507cc5d99ac056fe Mon Sep 17 00:00:00 2001 From: Peter Oliver Date: Tue, 15 May 2018 16:52:54 +0100 Subject: [PATCH] pkg returns 4 for "nothing to do" (#23007) * pkg returns 4 for "nothing to do" We need to handle this because our own checking for whether there's anything to do returns false negatives in certain circumstances. We need to rename the response `rc`, because that name is reserved by Ansible to indicate a failure if it is non-zero. Fixes ansible/ansible#22781 and ansible/ansible-modules-extras#932. * Don't rename `rc` to to `pkg_rc`, and instead override the failure state. * Drop mention of renamed variable in `pkg5` module. --- lib/ansible/modules/packaging/os/pkg5.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/packaging/os/pkg5.py b/lib/ansible/modules/packaging/os/pkg5.py index 755f114b52..ac807d5c7d 100644 --- a/lib/ansible/modules/packaging/os/pkg5.py +++ b/lib/ansible/modules/packaging/os/pkg5.py @@ -131,7 +131,10 @@ def ensure(module, state, packages, params): response['results'].append(out) response['msg'] += err response['changed'] = True - if rc != 0: + if rc == 4: + response['changed'] = False + response['failed'] = False + elif rc != 0: module.fail_json(**response) module.exit_json(**response)