From e42c58e1f5e987fcaa9c1a8d7fbcb1c1cc498d19 Mon Sep 17 00:00:00 2001 From: Steve Smith Date: Mon, 25 Nov 2019 14:28:56 +1100 Subject: [PATCH 1/8] DCD-791: Create a link to redirect local attachments to the shared home. --- roles/confluence_config/tasks/main.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/roles/confluence_config/tasks/main.yml b/roles/confluence_config/tasks/main.yml index f1e69fc..372b03a 100644 --- a/roles/confluence_config/tasks/main.yml +++ b/roles/confluence_config/tasks/main.yml @@ -13,6 +13,18 @@ - "{{ atl_product_shared_plugins }}" changed_when: false # For Molecule idempotence check +- name: Symlink local attachments to shared storage + # Create symlink to force single (unclustered) Confluence to store + # attachment in the shared drive. + file: + path: "{{ atl_product_home_shared }}/attachments/" + dest: "{{ atl_product_home }}/attachments/" + force: false + state: link + mode: 0750 + owner: "{{ atl_product_user }}" + group: "{{ atl_product_user }}" + - name: Create Tomcat server config template: From 7ec6e9eb37599ce6770629c6b8037093af1751a8 Mon Sep 17 00:00:00 2001 From: Steve Smith Date: Mon, 25 Nov 2019 14:32:51 +1100 Subject: [PATCH 2/8] DCD-791: Create the shared attachments directory up front. --- roles/confluence_config/tasks/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/roles/confluence_config/tasks/main.yml b/roles/confluence_config/tasks/main.yml index 372b03a..fe52a95 100644 --- a/roles/confluence_config/tasks/main.yml +++ b/roles/confluence_config/tasks/main.yml @@ -10,6 +10,7 @@ with_items: - "{{ atl_product_home }}" - "{{ atl_product_home_shared }}" + - "{{ atl_product_home_shared }}/attachments" - "{{ atl_product_shared_plugins }}" changed_when: false # For Molecule idempotence check From b64961cb967b4f372dbbc957521db6eaffd191a8 Mon Sep 17 00:00:00 2001 From: Steve Smith Date: Mon, 25 Nov 2019 15:36:07 +1100 Subject: [PATCH 3/8] DCD-791: Symlink both the local shared-home and attachments into the shared drive. --- roles/confluence_config/tasks/main.yml | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/roles/confluence_config/tasks/main.yml b/roles/confluence_config/tasks/main.yml index fe52a95..b560dab 100644 --- a/roles/confluence_config/tasks/main.yml +++ b/roles/confluence_config/tasks/main.yml @@ -14,11 +14,26 @@ - "{{ atl_product_shared_plugins }}" changed_when: false # For Molecule idempotence check +# Create symlink to force single (unclustered) Confluence to store +# shared-data and attachments in the shared drive. - name: Symlink local attachments to shared storage - # Create symlink to force single (unclustered) Confluence to store - # attachment in the shared drive. file: - path: "{{ atl_product_home_shared }}/attachments/" + src: "{{ item[0] }}" + dest: "{{ item[1] }}" + force: false + state: link + mode: 0750 + owner: "{{ atl_product_user }}" + group: "{{ atl_product_user }}" + with_items: + - ["{{ atl_product_home_shared }}/", + "{{ atl_product_home }}/shared-home/"] + - ["{{ atl_product_home_shared }}/attachments/", + "{{ atl_product_home }}/attachments/"] + +- name: Symlink local attachments to shared storage + file: + src: "{{ atl_product_home_shared }}/attachments/" dest: "{{ atl_product_home }}/attachments/" force: false state: link From d02b7a6e4e95ace173c13d7ba652dca7dd0a7a35 Mon Sep 17 00:00:00 2001 From: Steve Smith Date: Mon, 25 Nov 2019 15:40:00 +1100 Subject: [PATCH 4/8] DCD-791: Remove duplicate task. --- roles/confluence_config/tasks/main.yml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/roles/confluence_config/tasks/main.yml b/roles/confluence_config/tasks/main.yml index b560dab..24e68b8 100644 --- a/roles/confluence_config/tasks/main.yml +++ b/roles/confluence_config/tasks/main.yml @@ -30,17 +30,6 @@ "{{ atl_product_home }}/shared-home/"] - ["{{ atl_product_home_shared }}/attachments/", "{{ atl_product_home }}/attachments/"] - -- name: Symlink local attachments to shared storage - file: - src: "{{ atl_product_home_shared }}/attachments/" - dest: "{{ atl_product_home }}/attachments/" - force: false - state: link - mode: 0750 - owner: "{{ atl_product_user }}" - group: "{{ atl_product_user }}" - - name: Create Tomcat server config template: From deff784b6aae4fde1b5d6228c50d969c92aa5ddb Mon Sep 17 00:00:00 2001 From: Steve Smith Date: Mon, 25 Nov 2019 16:24:14 +1100 Subject: [PATCH 5/8] DCD-791: Ansible flattens nested lists, so use maps. --- roles/confluence_config/tasks/main.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/roles/confluence_config/tasks/main.yml b/roles/confluence_config/tasks/main.yml index 24e68b8..5a1f10e 100644 --- a/roles/confluence_config/tasks/main.yml +++ b/roles/confluence_config/tasks/main.yml @@ -18,18 +18,18 @@ # shared-data and attachments in the shared drive. - name: Symlink local attachments to shared storage file: - src: "{{ item[0] }}" - dest: "{{ item[1] }}" + src: "{{ item.from }}" + dest: "{{ item.to }}" force: false state: link mode: 0750 owner: "{{ atl_product_user }}" group: "{{ atl_product_user }}" with_items: - - ["{{ atl_product_home_shared }}/", - "{{ atl_product_home }}/shared-home/"] - - ["{{ atl_product_home_shared }}/attachments/", - "{{ atl_product_home }}/attachments/"] + - {from:: "{{ atl_product_home_shared }}/", + to: "{{ atl_product_home }}/shared-home/"} + - {from: "{{ atl_product_home_shared }}/attachments/", + to: "{{ atl_product_home }}/attachments/"} - name: Create Tomcat server config template: From 8f521d7d9571cca0a1af61fe6ee7179d3cded730 Mon Sep 17 00:00:00 2001 From: Steve Smith Date: Tue, 26 Nov 2019 08:58:19 +1100 Subject: [PATCH 6/8] DCD-791: Use nested lists. --- roles/confluence_config/tasks/main.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/roles/confluence_config/tasks/main.yml b/roles/confluence_config/tasks/main.yml index 5a1f10e..365dce8 100644 --- a/roles/confluence_config/tasks/main.yml +++ b/roles/confluence_config/tasks/main.yml @@ -18,18 +18,19 @@ # shared-data and attachments in the shared drive. - name: Symlink local attachments to shared storage file: - src: "{{ item.from }}" - dest: "{{ item.to }}" + src: "{{ item.0 }}" + dest: "{{ item.1 }}" force: false state: link mode: 0750 owner: "{{ atl_product_user }}" group: "{{ atl_product_user }}" - with_items: - - {from:: "{{ atl_product_home_shared }}/", - to: "{{ atl_product_home }}/shared-home/"} - - {from: "{{ atl_product_home_shared }}/attachments/", - to: "{{ atl_product_home }}/attachments/"} + vars: + - links: + - ["{{ atl_product_home_shared }}/", "{{ atl_product_home }}/shared-home/"] + - ["{{ atl_product_home_shared }}/attachments/", "{{ atl_product_home }}/attachments/"] + with_nested: + - "{{ links }}" - name: Create Tomcat server config template: From 883df8e1ea800cffc9bfef3887546171bb29fc1c Mon Sep 17 00:00:00 2001 From: Steve Smith Date: Tue, 26 Nov 2019 09:00:42 +1100 Subject: [PATCH 7/8] DCD-791: Remove trailing slashes. --- roles/confluence_config/tasks/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/confluence_config/tasks/main.yml b/roles/confluence_config/tasks/main.yml index 365dce8..55b8541 100644 --- a/roles/confluence_config/tasks/main.yml +++ b/roles/confluence_config/tasks/main.yml @@ -27,8 +27,8 @@ group: "{{ atl_product_user }}" vars: - links: - - ["{{ atl_product_home_shared }}/", "{{ atl_product_home }}/shared-home/"] - - ["{{ atl_product_home_shared }}/attachments/", "{{ atl_product_home }}/attachments/"] + - ["{{ atl_product_home_shared }}/", "{{ atl_product_home }}/shared-home"] + - ["{{ atl_product_home_shared }}/attachments/", "{{ atl_product_home }}/attachments"] with_nested: - "{{ links }}" From 0a716a29ed8ec3ccb1ca6a2bad9c04f2d8199d55 Mon Sep 17 00:00:00 2001 From: Steve Smith Date: Wed, 27 Nov 2019 11:59:00 +1100 Subject: [PATCH 8/8] DCD-791: Make linter happy and add symlink test. --- .../molecule/default/tests/test_default.py | 10 ++++++++++ roles/confluence_config/tasks/main.yml | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/roles/confluence_config/molecule/default/tests/test_default.py b/roles/confluence_config/molecule/default/tests/test_default.py index a8d3013..16c0a94 100644 --- a/roles/confluence_config/molecule/default/tests/test_default.py +++ b/roles/confluence_config/molecule/default/tests/test_default.py @@ -16,6 +16,16 @@ def test_conf_init_file(host): assert f.exists assert f.contains('confluence.home = /var/atlassian/application-data/confluence') +def test_conf_attachment_symlinks(host): + assert host.file('/var/atlassian/application-data/confluence').is_directory + assert host.file('/media/atl/confluence/shared-home/attachments/').is_directory + + f = host.file('/var/atlassian/application-data/confluence/attachments') + assert f.is_symlink and f.linked_to == '/media/atl/confluence/shared-home/attachments' + + f = host.file('/var/atlassian/application-data/confluence/shared-home') + assert f.is_symlink and f.linked_to == '/media/atl/confluence/shared-home' + def test_setenv_file(host): f = host.file('/opt/atlassian/confluence/current/bin/setenv.sh') assert f.exists diff --git a/roles/confluence_config/tasks/main.yml b/roles/confluence_config/tasks/main.yml index 55b8541..80473c8 100644 --- a/roles/confluence_config/tasks/main.yml +++ b/roles/confluence_config/tasks/main.yml @@ -27,8 +27,8 @@ group: "{{ atl_product_user }}" vars: - links: - - ["{{ atl_product_home_shared }}/", "{{ atl_product_home }}/shared-home"] - - ["{{ atl_product_home_shared }}/attachments/", "{{ atl_product_home }}/attachments"] + - ["{{ atl_product_home_shared }}/", "{{ atl_product_home }}/shared-home"] + - ["{{ atl_product_home_shared }}/attachments/", "{{ atl_product_home }}/attachments"] with_nested: - "{{ links }}"