2020-11-20 23:12:04 +01:00
|
|
|
---
|
2020-11-23 21:39:50 +01:00
|
|
|
- name: Setup
|
2022-06-03 12:22:17 +02:00
|
|
|
ansible.builtin.include_tasks: setup.yml
|
2020-11-23 21:39:50 +01:00
|
|
|
|
2020-11-20 23:12:04 +01:00
|
|
|
- name: Create a temporary directory for backup files
|
2022-06-03 12:22:17 +02:00
|
|
|
ansible.builtin.tempfile:
|
2020-11-20 23:12:04 +01:00
|
|
|
state: directory
|
|
|
|
register: __sshd_test_backup
|
2021-04-07 20:12:03 +02:00
|
|
|
changed_when: false
|
2020-11-20 23:12:04 +01:00
|
|
|
when:
|
|
|
|
- sshd_test_backup_skip is not defined
|
|
|
|
|
|
|
|
- name: Backup files
|
2022-06-03 12:22:17 +02:00
|
|
|
ansible.builtin.shell: |
|
2021-04-07 20:12:03 +02:00
|
|
|
if set -o | grep pipefail 2>&1 /dev/null ; then
|
2021-04-10 18:11:13 +02:00
|
|
|
set -o pipefail
|
2021-04-07 20:12:03 +02:00
|
|
|
fi
|
|
|
|
set -eu
|
2020-11-20 23:12:04 +01:00
|
|
|
if test -f {{ item }}; then
|
2021-04-07 20:12:03 +02:00
|
|
|
mkdir -p {{ __sshd_test_backup.path }}/$(dirname {{ item }})
|
2023-11-17 16:28:26 +01:00
|
|
|
cp -a {{ item }} {{ __sshd_test_backup.path }}/$(dirname {{ item }})
|
2020-11-20 23:12:04 +01:00
|
|
|
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
|