2020-11-20 23:12:04 +01:00
|
|
|
---
|
|
|
|
- name: Restore backed up files and remove what was not present
|
2022-06-03 12:22:17 +02:00
|
|
|
ansible.builtin.shell: |
|
2021-04-07 20:12:03 +02:00
|
|
|
set -eu
|
|
|
|
if set -o | grep pipefail 2>&1 /dev/null ; then
|
|
|
|
set -o pipefail
|
|
|
|
fi
|
2020-11-20 23:12:04 +01:00
|
|
|
if test -f {{ __sshd_test_backup.path }}/{{ item }}; then
|
|
|
|
cp {{ __sshd_test_backup.path }}/{{ item }} $(dirname {{ item }})
|
|
|
|
elif test -f {{ item }}; then
|
|
|
|
rm {{ item }}
|
|
|
|
fi
|
2021-04-07 20:12:03 +02:00
|
|
|
changed_when: false
|
2020-11-20 23:12:04 +01:00
|
|
|
loop: "{{ __sshd_test_backup_files | d([]) }}"
|
|
|
|
when:
|
|
|
|
- __sshd_test_backup is defined
|
|
|
|
- __sshd_test_backup.path is defined
|
|
|
|
|
|
|
|
- name: Remove temporary directory for backup files
|
2022-06-03 12:22:17 +02:00
|
|
|
ansible.builtin.file:
|
2020-11-20 23:12:04 +01:00
|
|
|
path: "{{ __sshd_test_backup.path }}"
|
|
|
|
state: absent
|
2021-04-07 20:12:03 +02:00
|
|
|
changed_when: false
|
2020-11-20 23:12:04 +01:00
|
|
|
when:
|
|
|
|
- __sshd_test_backup is defined
|
|
|
|
- __sshd_test_backup.path is defined
|
|
|
|
|
2022-04-12 12:18:24 +02:00
|
|
|
- name: Include common variables
|
2022-08-17 17:31:00 +02:00
|
|
|
ansible.builtin.include_role:
|
|
|
|
name: ansible-sshd
|
|
|
|
tasks_from: variables.yml
|
2022-04-12 12:18:24 +02:00
|
|
|
|
2020-11-20 23:12:04 +01:00
|
|
|
- name: Restart sshd service
|
2022-06-03 12:22:17 +02:00
|
|
|
ansible.builtin.service:
|
2020-11-20 23:12:04 +01:00
|
|
|
name: sshd
|
|
|
|
state: reloaded
|
2021-04-07 20:12:03 +02:00
|
|
|
changed_when: false
|
2020-11-20 23:12:04 +01:00
|
|
|
when:
|
|
|
|
- __sshd_test_backup is defined
|
2022-04-11 19:36:03 +02:00
|
|
|
- ansible_virtualization_type|default(None) not in __sshd_skip_virt_env
|
2020-11-20 23:12:04 +01:00
|
|
|
- ansible_connection != 'chroot'
|
|
|
|
- ansible_os_family != 'AIX'
|