From b1643eccee7ce138a0e2340b088702de926476da Mon Sep 17 00:00:00 2001 From: Ben Partridge Date: Wed, 13 Nov 2019 17:31:06 +1100 Subject: [PATCH] DCD-802: become product user when unarchiving shared home. Implement test that shared home is owned by correct user --- roles/restore_backups/molecule/restore/playbook.yml | 5 ++--- .../restore_backups/molecule/restore/tests/test_default.py | 6 ++++++ roles/restore_backups/tasks/main.yml | 3 +-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/roles/restore_backups/molecule/restore/playbook.yml b/roles/restore_backups/molecule/restore/playbook.yml index b3c60b0..e2f8157 100644 --- a/roles/restore_backups/molecule/restore/playbook.yml +++ b/roles/restore_backups/molecule/restore/playbook.yml @@ -6,6 +6,5 @@ atl_product_user: 'jira' atl_backup_home_restore_canary_path: '/tmp/canary.tmp' - tasks: - - name: Install distro-specific restore support packages - include_tasks: "../../tasks/{{ ansible_distribution|lower }}.yml" + roles: + - restore_backups diff --git a/roles/restore_backups/molecule/restore/tests/test_default.py b/roles/restore_backups/molecule/restore/tests/test_default.py index 6f88a4f..d8ec2b2 100644 --- a/roles/restore_backups/molecule/restore/tests/test_default.py +++ b/roles/restore_backups/molecule/restore/tests/test_default.py @@ -18,3 +18,9 @@ def test_postgresql_amazon_linux_extras_exes(host, exe): def test_postgresql_version(host): pg_dump_version_output = host.check_output('pg_dump --version') assert '(PostgreSQL) 9.6' in pg_dump_version_output + +def test_shared_home_owner(host): + for root, dirs, files in os.walk('/media/atl/jira/shared'): + for fileName in files + dirs: + assert host.file(fileName).user == 'jira' + assert host.file(fileName).group == 'jira' \ No newline at end of file diff --git a/roles/restore_backups/tasks/main.yml b/roles/restore_backups/tasks/main.yml index 1f9ebdb..825517b 100644 --- a/roles/restore_backups/tasks/main.yml +++ b/roles/restore_backups/tasks/main.yml @@ -124,8 +124,7 @@ unarchive: src: "{{ atl_backup_home_dest }}" dest: "{{ atl_product_home_shared }}" - owner: "{{ atl_product_user }}" - group: "{{ atl_product_user }}" + become: "{{ atl_product_user }}" - name: Create restore-canary if necessary copy: