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.
pull/40095/merge
Peter Oliver 7 years ago committed by ansibot
parent def434b5c3
commit caddf863df

@ -131,7 +131,10 @@ def ensure(module, state, packages, params):
response['results'].append(out) response['results'].append(out)
response['msg'] += err response['msg'] += err
response['changed'] = True response['changed'] = True
if rc != 0: if rc == 4:
response['changed'] = False
response['failed'] = False
elif rc != 0:
module.fail_json(**response) module.fail_json(**response)
module.exit_json(**response) module.exit_json(**response)

Loading…
Cancel
Save