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:
parent
0d0f8217cf
commit
86a5950efa
3 changed files with 18 additions and 10 deletions
|
|
@ -410,12 +410,13 @@
|
|||
# -------------------------------------------------------------
|
||||
# check mode
|
||||
|
||||
- name: copy an existing file in place with comments
|
||||
- name: CHECK MODE | copy an existing file in place with comments
|
||||
copy:
|
||||
src: existing_authorized_keys
|
||||
dest: "{{ output_dir | expanduser }}/authorized_keys"
|
||||
|
||||
- authorized_key:
|
||||
- name: CHECK MODE | add key in check mode to validate return codes
|
||||
authorized_key:
|
||||
user: root
|
||||
key: "{{ multiple_key_different_order_2 }}"
|
||||
state: present
|
||||
|
|
@ -423,13 +424,21 @@
|
|||
check_mode: True
|
||||
register: result
|
||||
|
||||
- name: assert that the file was not changed
|
||||
- name: CHECK MODE | assert that authorized_keys return values are consistent
|
||||
assert:
|
||||
that:
|
||||
- 'result.changed == True'
|
||||
- '"user" in result'
|
||||
- '"key" in result'
|
||||
|
||||
- name: CHECK MODE | recopy authorized_keys to ensure it was not changed
|
||||
copy:
|
||||
src: existing_authorized_keys
|
||||
dest: "{{ output_dir | expanduser }}/authorized_keys"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
- name: CHECK MODE | assert that the authorized_keys file was not changed
|
||||
assert:
|
||||
that:
|
||||
- 'result.changed == False'
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue