mirror of
https://github.com/ansible-collections/ansible.posix.git
synced 2026-05-15 05:52:03 +00:00
refactor to comply with current ansible-lint and sanity guidelines
Signed-off-by: Adam Miller <admiller@redhat.com>
This commit is contained in:
@@ -1,34 +1,37 @@
|
||||
---
|
||||
# -------------------------------------------------------------
|
||||
# check mode
|
||||
|
||||
- name: CHECK MODE | copy an existing file in place with comments
|
||||
copy:
|
||||
ansible.builtin.copy:
|
||||
src: existing_authorized_keys
|
||||
dest: "{{ output_dir | expanduser }}/authorized_keys"
|
||||
mode: "0600"
|
||||
|
||||
- name: CHECK MODE | add key in check mode to validate return codes
|
||||
authorized_key:
|
||||
ansible.posix.authorized_key:
|
||||
user: root
|
||||
key: "{{ multiple_key_different_order_2 }}"
|
||||
state: present
|
||||
path: "{{ output_dir | expanduser }}/authorized_keys"
|
||||
check_mode: True
|
||||
check_mode: true
|
||||
register: result
|
||||
|
||||
- name: CHECK MODE | assert that authorized_keys return values are consistent
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- 'result.changed == True'
|
||||
- result.changed == True
|
||||
- '"user" in result'
|
||||
- '"key" in result'
|
||||
|
||||
- name: CHECK MODE | recopy authorized_keys to ensure it was not changed
|
||||
copy:
|
||||
ansible.builtin.copy:
|
||||
src: existing_authorized_keys
|
||||
dest: "{{ output_dir | expanduser }}/authorized_keys"
|
||||
mode: "0600"
|
||||
register: result
|
||||
|
||||
- name: CHECK MODE | assert that the authorized_keys file was not changed
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- 'result.changed == False'
|
||||
- result.changed == False
|
||||
|
||||
Reference in New Issue
Block a user