1
0
Fork 0
mirror of https://github.com/ansible-collections/ansible.posix.git synced 2026-02-04 08:01:49 +00:00

authorized_keys - consistent behavior in check_mode

Previously check_mode would incorrectly return changed=False even when a
change would have taken place if ran without check_mode, with
integration tests that confirmed this incorrect behavior. Also the
module did not correctly populate the return values when run in
check_mode. Both of these issues are resolved in this PR.

Fixes https://github.com/ansible-collections/ansible.posix/issues/37

Signed-off-by: Adam Miller <admiller@redhat.com>
This commit is contained in:
Adam Miller 2020-06-18 23:01:06 -05:00
parent 0d0f8217cf
commit 86a5950efa
3 changed files with 18 additions and 10 deletions

View file

@ -635,13 +635,9 @@ def enforce_state(module, params):
}
params['diff'] = diff
if module.check_mode:
module.exit_json(changed=True, diff=diff)
writefile(module, filename, new_content)
if not module.check_mode:
writefile(module, filename, new_content)
params['changed'] = True
else:
if module.check_mode:
module.exit_json(changed=False)
return params