DCD-802: Add test and logic for setting version file owner to root in

shared home
This commit is contained in:
Ben Partridge
2019-11-18 16:59:56 +11:00
parent 4827ae8423
commit 688be1f5d7
3 changed files with 28 additions and 4 deletions

View File

@@ -4,6 +4,8 @@
vars: vars:
atl_backup_manifest_url: 's3://dcd-slingshot-test/dummy_manifest.json' atl_backup_manifest_url: 's3://dcd-slingshot-test/dummy_manifest.json'
atl_product_user: 'jira' 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_product_user_uid: '2001'
atl_backup_home_restore_canary_path: '/tmp/canary.tmp' atl_backup_home_restore_canary_path: '/tmp/canary.tmp'
atl_product_home_shared: '/media/atl/jira/shared' atl_product_home_shared: '/media/atl/jira/shared'
@@ -12,6 +14,7 @@
test_archive_source: '/tmp/hello' test_archive_source: '/tmp/hello'
test_archive_file: 'hello.txt' test_archive_file: 'hello.txt'
test_product_version_file: "/tmp/{{ atl_product_edition }}.version"
test_archive: '/tmp/hello.tar.gz' test_archive: '/tmp/hello.tar.gz'
test_pre_step_prefix: '[PRE-TEST]' test_pre_step_prefix: '[PRE-TEST]'
@@ -47,9 +50,16 @@
create: yes create: yes
line: 'Hello, world!' line: 'Hello, world!'
path: "{{ test_archive_source }}/{{ test_archive_file }}" 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" - name: "{{ test_pre_step_prefix }} Archive the shared home"
archive: archive:
path: "{{ test_archive_source }}" path:
- "{{ test_archive_source }}"
- "{{ test_product_version_file }}"
dest: "{{ test_archive }}" dest: "{{ test_archive }}"
owner: "{{ atl_product_user }}" owner: "{{ atl_product_user }}"

View File

@@ -27,4 +27,9 @@ def test_postgresql_version(host):
def test_shared_home_owner(host, file): def test_shared_home_owner(host, file):
assert host.file(file).exists assert host.file(file).exists
assert host.file(file).user == 'jira' assert host.file(file).user == 'jira'
assert host.file(file).group == 'jira' 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'

View File

@@ -20,14 +20,23 @@
dest: "{{ atl_product_home_shared }}" dest: "{{ atl_product_home_shared }}"
mode: 0640 mode: 0640
- name: Set shared home file owner to application user - name: Set shared home owner and group to application user
file: file:
path: "{{ atl_product_home_shared }}" path: "{{ atl_product_home_shared }}"
recurse: yes recurse: yes
group: "{{ atl_product_user }}" group: "{{ atl_product_user }}"
owner: "{{ atl_product_user }}"
state: directory state: directory
mode: 0640 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 - name: Create restore-canary if necessary
copy: copy: