From 39382b4677b02217a8a4e00c0aa0d1c5d94f235c Mon Sep 17 00:00:00 2001 From: Rich Megginson Date: Tue, 14 Nov 2023 14:58:30 -0700 Subject: [PATCH] tests: Ensure backup/restore preserves file attributes I noticed some test failures in tests that check ownership/permissions of config files. The tests were recently changed to reuse the same VM, so I suspect config files were not being backed up/restored with the correct file attributes. Use `cp -a` to preserve all file attributes. Signed-off-by: Rich Megginson --- tests/tasks/backup.yml | 2 +- tests/tasks/restore.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/tasks/backup.yml b/tests/tasks/backup.yml index e97dd18..a6e5d96 100644 --- a/tests/tasks/backup.yml +++ b/tests/tasks/backup.yml @@ -14,7 +14,7 @@ shell: > if test -f {{ item }}; then mkdir -p {{ __ssh_test_backup.path }}/$(dirname {{ item }}); - cp {{ item }} {{ __ssh_test_backup.path }}/$(dirname {{ item }}) + cp -a {{ item }} {{ __ssh_test_backup.path }}/$(dirname {{ item }}) fi changed_when: false loop: "{{ __ssh_test_backup_files | d([]) }}" diff --git a/tests/tasks/restore.yml b/tests/tasks/restore.yml index 9760fee..0083741 100644 --- a/tests/tasks/restore.yml +++ b/tests/tasks/restore.yml @@ -2,7 +2,7 @@ - name: Restore backed up files and remove what was not present shell: > if test -f {{ __ssh_test_backup.path }}/{{ item }}; then - cp {{ __ssh_test_backup.path }}/{{ item }} $(dirname {{ item }}) + cp -a {{ __ssh_test_backup.path }}/{{ item }} $(dirname {{ item }}) elif test -f {{ item }}; then rm {{ item }} fi