diff --git a/roles/restore_backups/molecule/restore/playbook.yml b/roles/restore_backups/molecule/restore/playbook.yml index d174e48..3e4272c 100644 --- a/roles/restore_backups/molecule/restore/playbook.yml +++ b/roles/restore_backups/molecule/restore/playbook.yml @@ -4,6 +4,8 @@ vars: atl_backup_manifest_url: 's3://dcd-slingshot-test/dummy_manifest.json' atl_product_user: 'jira' + atl_product_edition: 'jira-software' + atl_product_version_cache: "{{ atl_product_home_shared }}/{{ atl_product_edition }}.version" atl_product_user_uid: '2001' atl_backup_home_restore_canary_path: '/tmp/canary.tmp' atl_product_home_shared: '/media/atl/jira/shared' @@ -12,6 +14,7 @@ test_archive_source: '/tmp/hello' test_archive_file: 'hello.txt' + test_product_version_file: "/tmp/{{ atl_product_edition }}.version" test_archive: '/tmp/hello.tar.gz' test_pre_step_prefix: '[PRE-TEST]' @@ -47,9 +50,16 @@ create: yes line: 'Hello, world!' path: "{{ test_archive_source }}/{{ test_archive_file }}" + - name: "{{ test_pre_step_prefix }} Create the version file in the shared home" + lineinfile: + create: yes + line: '8.5' + path: "{{ test_product_version_file }}" - name: "{{ test_pre_step_prefix }} Archive the shared home" archive: - path: "{{ test_archive_source }}" + path: + - "{{ test_archive_source }}" + - "{{ test_product_version_file }}" dest: "{{ test_archive }}" owner: "{{ atl_product_user }}" diff --git a/roles/restore_backups/molecule/restore/tests/test_default.py b/roles/restore_backups/molecule/restore/tests/test_default.py index f8ab676..98af566 100644 --- a/roles/restore_backups/molecule/restore/tests/test_default.py +++ b/roles/restore_backups/molecule/restore/tests/test_default.py @@ -27,4 +27,9 @@ def test_postgresql_version(host): def test_shared_home_owner(host, file): assert host.file(file).exists assert host.file(file).user == 'jira' - assert host.file(file).group == 'jira' \ No newline at end of file + assert host.file(file).group == 'jira' + +def test_version_file_owned_by_root(host): + assert host.file('/media/atl/jira/shared/jira-software.version').exists + assert host.file('/media/atl/jira/shared/jira-software.version').user == 'root' + assert host.file('/media/atl/jira/shared/jira-software.version').group == 'root' \ No newline at end of file diff --git a/roles/restore_backups/tasks/home_restore.yml b/roles/restore_backups/tasks/home_restore.yml index 2a9fa1f..c3cb081 100644 --- a/roles/restore_backups/tasks/home_restore.yml +++ b/roles/restore_backups/tasks/home_restore.yml @@ -20,14 +20,23 @@ dest: "{{ atl_product_home_shared }}" mode: 0640 - - name: Set shared home file owner to application user + - name: Set shared home owner and group to application user file: path: "{{ atl_product_home_shared }}" recurse: yes group: "{{ atl_product_user }}" + owner: "{{ atl_product_user }}" state: directory mode: 0640 - owner: "{{ atl_product_user }}" + + - name: Set version file owner and group to root + file: + path: "{{ atl_product_version_cache }}" + group: root + owner: root + state: file + # Ignore the error in case there is no product version file in the backup + ignore_errors: yes - name: Create restore-canary if necessary copy: