mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-02 14:40:19 -07:00
authorized_key: support --diff (#19277)
* Refactoring: split readkeys() into readfile() and parsekeys() * Refactoring: split writekeys() into writefile() and serialize() * authorized_key: support --diff * Refactoring: remove no-longer used readkeys()/writekeys() * Integration test for authorized_key in check mode
This commit is contained in:
parent
5c36bd6714
commit
b0b7a636d8
2 changed files with 87 additions and 40 deletions
|
@ -396,3 +396,30 @@
|
|||
assert:
|
||||
that:
|
||||
- 'content.stdout == "no-agent-forwarding,no-X11-forwarding,permitopen=\"10.9.8.1:8080\",permitopen=\"10.9.8.1:9001\" ssh-dss DATA_BASIC root@testing"'
|
||||
|
||||
# -------------------------------------------------------------
|
||||
# check mode
|
||||
|
||||
- name: copy an existing file in place with comments
|
||||
copy: src=existing_authorized_keys dest="{{output_dir|expanduser}}/authorized_keys"
|
||||
|
||||
- authorized_key:
|
||||
user: root
|
||||
key: "{{ multiple_key_different_order_2 }}"
|
||||
state: present
|
||||
path: "{{output_dir|expanduser}}/authorized_keys"
|
||||
check_mode: True
|
||||
register: result
|
||||
|
||||
- name: assert that the key would be added and that the diff is shown
|
||||
assert:
|
||||
that:
|
||||
- 'result.changed'
|
||||
- '"ssh-rsa WHATEVER 2.5@testing" in result.diff.after'
|
||||
|
||||
- name: assert that the file was not changed
|
||||
copy: src=existing_authorized_keys dest="{{output_dir|expanduser}}/authorized_keys"
|
||||
register: result
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == False'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue