ansible-sshd/tests/tasks/backup.yml

28 lines
748 B
YAML
Raw Normal View History

---
- name: Setup
2022-06-03 12:22:17 +02:00
ansible.builtin.include_tasks: setup.yml
- name: Create a temporary directory for backup files
2022-06-03 12:22:17 +02:00
ansible.builtin.tempfile:
state: directory
register: __sshd_test_backup
changed_when: false
when:
- sshd_test_backup_skip is not defined
- name: Backup files
2022-06-03 12:22:17 +02:00
ansible.builtin.shell: |
if set -o | grep pipefail 2>&1 /dev/null ; then
set -o pipefail
fi
set -eu
if test -f {{ item }}; then
mkdir -p {{ __sshd_test_backup.path }}/$(dirname {{ item }})
cp -a {{ item }} {{ __sshd_test_backup.path }}/$(dirname {{ item }})
fi
changed_when: false
loop: "{{ __sshd_test_backup_files | d([]) }}"
when:
- __sshd_test_backup is defined
- __sshd_test_backup.path is defined