DCD-224: Refactor installer role to work around various quirks.

This commit is contained in:
Steve Smith
2019-05-08 12:13:29 +10:00
parent a5eefe326e
commit 1aa2afc6f2
19 changed files with 86 additions and 68 deletions

View File

@@ -1,6 +1,7 @@
--- ---
atl_product_latest_version_url: "https://marketplace.atlassian.com/rest/2/applications/{{ atl_product_family }}/versions/latest" atl_product_latest_version_url: "https://marketplace.atlassian.com/rest/2/applications/{{ atl_product_family }}/versions/latest"
atl_product_version_cache_dir: "{{ atl_product_home_shared }}"
atl_product_version_cache: "{{ atl_product_home_shared }}/{{ atl_product_edition }}.version" atl_product_version_cache: "{{ atl_product_home_shared }}/{{ atl_product_edition }}.version"
atl_release_base_url: "https://product-downloads.atlassian.com/software" atl_release_base_url: "https://product-downloads.atlassian.com/software"

View File

@@ -19,7 +19,7 @@ def test_is_downloaded(host):
assert installer.user == 'root' assert installer.user == 'root'
def test_is_unpacked(host): def test_is_unpacked(host):
installer = host.file('/opt/atlassian/jira-core/7.9.0') installer = host.file('/opt/atlassian/jira-core/7.9.0/atlassian-jira/')
assert installer.exists assert installer.exists
assert installer.is_directory assert installer.is_directory
assert installer.user == 'jira' assert installer.user == 'jira'

View File

@@ -23,4 +23,3 @@ def test_is_unpacked(host):
assert installer.exists assert installer.exists
assert installer.is_directory assert installer.is_directory
assert installer.user == 'jira' assert installer.user == 'jira'
assert installer.mode == 0o0755

View File

@@ -11,27 +11,20 @@ def test_version_is_correct(host):
verfile = host.file('/media/atl/jira/shared/jira-servicedesk.version') verfile = host.file('/media/atl/jira/shared/jira-servicedesk.version')
assert verfile.exists assert verfile.exists
assert verfile.content.decode("UTF-8").strip() == "3.0.2" assert verfile.content.decode("UTF-8").strip() == "3.9.0"
def test_is_downloaded(host): def test_is_downloaded(host):
installer = host.file('/opt/atlassian/tmp/jira-software.7.0.11.tar.gz') installer = host.file('/opt/atlassian/tmp/servicedesk.3.9.0.bin')
assert installer.exists assert installer.exists
assert installer.user == 'root' assert installer.user == 'root'
def test_is_unpacked(host): def test_is_unpacked(host):
installer = host.file('/opt/atlassian/jira-servicedesk/3.0.2') installer = host.file('/opt/atlassian/jira-servicedesk/3.9.0')
assert installer.exists assert installer.exists
assert installer.is_directory assert installer.is_directory
assert installer.user == 'jira' assert installer.user == 'jira'
assert installer.mode == 0o0755
def test_sd_is_downloaded(host): def test_plugin_is_present(host):
installer = host.file('/opt/atlassian/tmp/jira-servicedesk.3.0.2.obr') installer = host.file('/opt/atlassian/jira-servicedesk/current/atlassian-jira/WEB-INF/application-installation/jira-servicedesk-application/jira-servicedesk-application-3.9.0.jar')
assert installer.exists
assert installer.user == 'root'
def test_is_unpacked(host):
installer = host.file('/media/atl/jira/shared/plugins/installed-plugins/jira-servicedesk-application-3.0.2.jar')
assert installer.exists assert installer.exists
assert installer.user == 'jira' assert installer.user == 'jira'
assert installer.mode == 0o0750

View File

@@ -14,7 +14,7 @@ def test_version_is_correct(host):
assert verfile.content.decode("UTF-8").strip() == "4.1.0" assert verfile.content.decode("UTF-8").strip() == "4.1.0"
def test_is_downloaded(host): def test_is_downloaded(host):
installer = host.file('/opt/atlassian/tmp/jira-software.8.1.0.tar.gz') installer = host.file('/opt/atlassian/tmp/servicedesk.4.1.0.bin')
assert installer.exists assert installer.exists
assert installer.user == 'root' assert installer.user == 'root'
@@ -23,15 +23,8 @@ def test_is_unpacked(host):
assert installer.exists assert installer.exists
assert installer.is_directory assert installer.is_directory
assert installer.user == 'jira' assert installer.user == 'jira'
assert installer.mode == 0o0755
def test_sd_is_downloaded(host): def test_plugin_is_present(host):
installer = host.file('/opt/atlassian/tmp/jira-servicedesk.4.1.0.obr') installer = host.file('/opt/atlassian/jira-servicedesk/current/atlassian-jira/WEB-INF/application-installation/jira-servicedesk-application/jira-servicedesk-application-4.1.0.jar')
assert installer.exists
assert installer.user == 'root'
def test_is_unpacked(host):
installer = host.file('/media/atl/jira/shared/plugins/installed-plugins/jira-servicedesk-application-4.1.0.jar')
assert installer.exists assert installer.exists
assert installer.user == 'jira' assert installer.user == 'jira'
assert installer.mode == 0o0750

View File

@@ -23,24 +23,17 @@ def test_version_is_correct(host):
assert verfile.content.decode("UTF-8").strip() == sd assert verfile.content.decode("UTF-8").strip() == sd
def test_is_downloaded(host): def test_is_downloaded(host):
installer = host.file('/opt/atlassian/tmp/jira-software.'+jira+'.tar.gz') installer = host.file('/opt/atlassian/tmp/servicedesk.'+sd+'.bin')
assert installer.exists assert installer.exists
assert installer.user == 'root' assert installer.user == 'root'
def test_is_unpacked(host): def test_is_unpacked(host):
installer = host.file('/opt/atlassian/jira-servicedesk/'+jira) installer = host.file('/opt/atlassian/jira-servicedesk/'+sd)
assert installer.exists assert installer.exists
assert installer.is_directory assert installer.is_directory
assert installer.user == 'jira' assert installer.user == 'jira'
assert installer.mode == 0o0755
def test_sd_is_downloaded(host): def test_plugin_is_present(host):
installer = host.file('/opt/atlassian/tmp/jira-servicedesk.'+sd+'.obr') installer = host.file('/opt/atlassian/jira-servicedesk/current/atlassian-jira/WEB-INF/application-installation/jira-servicedesk-application/jira-servicedesk-application-'+sd+'.jar')
assert installer.exists
assert installer.user == 'root'
def test_is_unpacked(host):
installer = host.file('/media/atl/jira/shared/plugins/installed-plugins/jira-servicedesk-application-'+sd+'.jar')
assert installer.exists assert installer.exists
assert installer.user == 'jira' assert installer.user == 'jira'
assert installer.mode == 0o0750

View File

@@ -0,0 +1,15 @@
---
- name: Create installation directories
file:
path: "{{ item }}"
state: directory
mode: 0750
owner: "{{ atl_product_user }}"
group: "{{ atl_product_user }}"
with_items:
- "{{ atl_installer_temp }}"
- "{{ atl_product_home }}"
- "{{ atl_product_installation_versioned }}"
- "{{ atl_product_version_cache_dir }}"
changed_when: false # For Molecule idempotence check

View File

@@ -15,11 +15,18 @@
template: template:
src: "{{ atl_product_family }}.varfile.j2" src: "{{ atl_product_family }}.varfile.j2"
dest: "{{ atl_product_varfile }}" dest: "{{ atl_product_varfile }}"
mode: 0755
# NOTE: We run the installer as the user rather than root to limit its
# actions. For example, if root and the 'jira' user exists then it
# will create 'jira1'; this potentially creates idempotency/upgrade
# issues down the line.
- name: Run the installer - name: Run the installer
command: /bin/sh "{{ atl_product_download }}" -q -varfile "{{ atl_product_varfile }}" command: /bin/sh "{{ atl_product_download }}" -q -varfile "{{ atl_product_varfile }}"
args: args:
creates: "{{ atl_product_installation_versioned }}/.install4j/" creates: "{{ atl_product_installation_versioned }}/.install4j/"
become: true
become_user: "{{ atl_product_user }}"
- name: Symlink the installed version to current - name: Symlink the installed version to current
file: file:

View File

@@ -1,15 +1,5 @@
--- ---
- name: Create installation directories
file:
path: "{{ item }}"
state: directory
mode: 0755
with_items:
- "{{ atl_installer_temp }}"
- "{{ atl_product_home_shared }}"
# Common case for most products and Jira editions. # Common case for most products and Jira editions.
- name: Fetch ServiceDesk metadata if necessary - name: Fetch ServiceDesk metadata if necessary
include_tasks: "servicedesk_download.yml" include_tasks: "servicedesk_download.yml"
@@ -17,7 +7,8 @@
# Differences for ServiceDesk become fiddly enough that it's better to # Differences for ServiceDesk become fiddly enough that it's better to
# just split them out and move common functionality into individual # just split them out and move common functionality into individual
# task files. # task files. This gives us some flexibility in the future if
# necessary.
- name: Fetch product metadata if necessary - name: Fetch product metadata if necessary
include_tasks: "product_download.yml" include_tasks: "product_download.yml"
when: atl_product_edition != "jira-servicedesk" when: atl_product_edition != "jira-servicedesk"

View File

@@ -1,5 +1,8 @@
--- ---
- name: Create installation directories if necesary
include_tasks: "create_dirs.yml"
- name: Check for and load cached version - name: Check for and load cached version
include_tasks: "cached_version_fetch.yml" include_tasks: "cached_version_fetch.yml"

View File

@@ -1,5 +1,8 @@
--- ---
- name: Create installation directories if necesary
include_tasks: "create_dirs.yml"
- name: Check for and load cached version - name: Check for and load cached version
include_tasks: "cached_version_fetch.yml" include_tasks: "cached_version_fetch.yml"
@@ -12,7 +15,7 @@
set_fact: set_fact:
atl_servicedesk_version_json: "{{ lookup('url', '{{ atl_servicedesk_latest_url }}') }}" atl_servicedesk_version_json: "{{ lookup('url', '{{ atl_servicedesk_latest_url }}') }}"
- name: Set the Jira version for ServiceDesk - name: Set the version for ServiceDesk
set_fact: set_fact:
atl_product_version: "{{ atl_servicedesk_version_json.name }}" atl_product_version: "{{ atl_servicedesk_version_json.name }}"

View File

@@ -12,5 +12,5 @@
roles: roles:
- role: linux_common - role: linux_common
- role: product_common - role: product_common
- role: tgz_download - role: installer_download
- role: jira_config - role: jira_config

View File

@@ -43,3 +43,11 @@ def test_server_file(host):
assert f.contains('scheme="http"') assert f.contains('scheme="http"')
assert not f.contains('proxyName=') assert not f.contains('proxyName=')
assert not f.contains('proxyPort=') assert not f.contains('proxyPort=')
def test_install_permissions(host):
assert host.file('/opt/atlassian/jira-software/current/conf/server.xml').user == 'root'
assert host.file('/opt/atlassian/jira-software/current/atlassian-jira/WEB-INF/web.xml').user == 'root'
assert host.file('/opt/atlassian/jira-software/current/logs/').user == 'root'
assert host.file('/opt/atlassian/jira-software/current/work/').user == 'root'
assert host.file('/opt/atlassian/jira-software/current/temp/').user == 'root'

View File

@@ -29,7 +29,6 @@
- 'JVM_MINIMUM_MEMORY' - 'JVM_MINIMUM_MEMORY'
- 'JVM_MAXIMUM_MEMORY' - 'JVM_MAXIMUM_MEMORY'
- name: Create application directories - name: Create application directories
file: file:
path: "{{ item }}" path: "{{ item }}"
@@ -38,5 +37,35 @@
owner: "{{ atl_product_user }}" owner: "{{ atl_product_user }}"
group: "{{ atl_product_user }}" group: "{{ atl_product_user }}"
with_items: with_items:
- "{{ atl_product_home }}"
- "{{ atl_product_home_shared }}" - "{{ atl_product_home_shared }}"
- "{{ atl_product_shared_plugins }}" - "{{ atl_product_shared_plugins }}"
changed_when: false # For Molecule idempotence check
- name: Limit permissions on the installation directory
file:
path: "{{ atl_product_installation_versioned }}"
owner: "root"
group: "root"
mode: "u=rwX,g=rX,o-rwx"
recurse: true
with_items:
- "{{ atl_installer_temp }}"
- "{{ atl_product_installation_versioned }}"
- "{{ atl_product_version_cache_dir }}"
changed_when: false # For Molecule idempotence check
- name: Grant access to the product working directories
file:
path: "{{ item }}"
state: directory
mode: 0750
owner: "root"
group: "root"
recurse: true
with_items:
- "{{ atl_product_installation_versioned }}/logs"
- "{{ atl_product_installation_versioned }}/temp"
- "{{ atl_product_installation_versioned }}/work"
changed_when: false # For Molecule idempotence check

View File

@@ -7,4 +7,3 @@ git_version: "2.14.4"
# Disable these when using the product installer, otherwise we end up # Disable these when using the product installer, otherwise we end up
# fighting with it. # fighting with it.
use_system_jdk: false use_system_jdk: false
create_product_user: false

View File

@@ -12,22 +12,9 @@ def test_user_created(host):
assert user.exists assert user.exists
@pytest.mark.parametrize('target', [
'/opt/atlassian/product',
'/opt/atlassian/temp',
'/media/atl/jira/shared'
])
def test_dirs_created(host, target):
d = host.file(target)
assert d.exists
assert d.is_directory
assert d.user == 'testuser'
@pytest.mark.parametrize('exe', [ @pytest.mark.parametrize('exe', [
'/usr/bin/git', '/usr/bin/git',
'/usr/bin/psql', '/usr/bin/psql'
'/usr/bin/javac'
]) ])
def test_package_exes(host, exe): def test_package_exes(host, exe):
assert host.file(exe).exists assert host.file(exe).exists

View File

@@ -7,4 +7,3 @@
user: user:
name: "{{ atl_product_user }}" name: "{{ atl_product_user }}"
comment: "Product runtime user" comment: "Product runtime user"
when: create_product_user

View File

@@ -14,5 +14,3 @@
- postgresql-client - postgresql-client
- fonts-dejavu-core - fonts-dejavu-core
- git - git
tags:
- runtime_pkg