DCD-484: Add ability to install from the tarball rather than the installer.

This commit is contained in:
Steve Smith
2019-07-11 12:42:28 +10:00
parent 26d2e4cbd4
commit 94a16a6731
8 changed files with 127 additions and 17 deletions

View File

@@ -8,9 +8,14 @@ atl_product_latest_version_url: "https://marketplace.atlassian.com/rest/2/applic
atl_product_version_cache_dir: "{{ atl_product_home_shared }}"
atl_product_version_cache: "{{ atl_product_home_shared }}/{{ atl_product_edition }}.version"
atl_download_format: 'installer'
atl_download_format_suffix_map:
installer: '-x64.bin'
tarball: '.tar.gz'
atl_release_base_url: "https://product-downloads.atlassian.com/software"
atl_product_base_url: "{{ atl_release_base_url }}/{{ atl_product_family }}/downloads"
atl_product_download_url: "{{ atl_product_base_url }}/atlassian-{{ atl_download_edition | default(atl_product_edition) }}-{{ atl_product_version }}-x64.bin"
atl_product_download_url: "{{ atl_product_base_url }}/atlassian-{{ atl_download_edition | default(atl_product_edition) }}-{{ atl_product_version }}{{ atl_download_format_suffix_map[atl_download_format] }}"
atl_product_download_filename: "{{ atl_download_edition | default(atl_product_edition) }}.{{ atl_product_version }}.bin"
atl_product_download: "{{ atl_installer_temp }}/{{ atl_product_download_filename }}"

View File

@@ -0,0 +1,14 @@
# Molecule managed
{% if item.registry is defined %}
FROM {{ item.registry.url }}/{{ item.image }}
{% else %}
FROM {{ item.image }}
{% endif %}
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python*-dnf bash && dnf clean all; \
elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml && zypper clean -a; \
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi

View File

@@ -0,0 +1,32 @@
---
dependency:
name: galaxy
driver:
name: docker
lint:
name: yamllint
platforms:
- name: amazon_linux2
image: amazonlinux:2
groups:
- aws_node_local
- name: ubuntu_lts
image: ubuntu:bionic
groups:
- aws_node_local
provisioner:
name: ansible
options:
skip-tags: runtime_pkg
lint:
name: ansible-lint
inventory:
links:
group_vars: ../../../../group_vars/
verifier:
name: testinfra
additional_files_or_dirs:
- ../../resources/tests/test_*.py
lint:
name: flake8
enabled: false

View File

@@ -0,0 +1,12 @@
---
- name: Converge
hosts: all
vars:
atl_product_family: "jira"
atl_product_edition: "jira-core"
atl_product_user: "jira"
atl_download_format: "tarball"
roles:
- role: linux_common
- role: product_common
- role: product_install

View File

@@ -0,0 +1,28 @@
import os
from six.moves import urllib
import testinfra.utils.ansible_runner
import json
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
def test_version_file_is_latest(host):
verfile = host.file('/media/atl/jira/shared/jira-core.version')
assert verfile.exists
upstream_fd = urllib.request.urlopen("https://marketplace.atlassian.com/rest/2/applications/jira/versions/latest")
upstream_json = json.load(upstream_fd)
upstream = upstream_json['version']
assert verfile.content.decode("UTF-8").strip() == upstream.strip()
def test_latest_is_downloaded(host):
upstream_fd = urllib.request.urlopen("https://marketplace.atlassian.com/rest/2/applications/jira/versions/latest")
upstream_json = json.load(upstream_fd)
upstream = upstream_json['version']
installer = host.file('/opt/atlassian/tmp/jira-core.'+upstream+'.bin')
assert installer.exists
assert installer.user == 'root'

View File

@@ -137,22 +137,8 @@
mode: 0755
force: false
- name: Create installer varfile
template:
src: "{{ atl_product_family }}.varfile.j2"
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
command: /bin/sh "{{ atl_product_download }}" -q -varfile "{{ atl_product_varfile }}"
args:
creates: "{{ atl_product_installation_versioned }}/.install4j/"
become: true
become_user: "{{ atl_product_user }}"
- name: Unpack the downloaded application depending on format
include_tasks: "unpack_{{ atl_download_format }}.yml"
- name: Symlink the installed version to current
file:

View File

@@ -0,0 +1,18 @@
---
- name: Create installer varfile
template:
src: "{{ atl_product_family }}.varfile.j2"
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
command: /bin/sh "{{ atl_product_download }}" -q -varfile "{{ atl_product_varfile }}"
args:
creates: "{{ atl_product_installation_versioned }}/.install4j/"
become: true
become_user: "{{ atl_product_user }}"

View File

@@ -0,0 +1,15 @@
---
- name: Unpack the product packages
unarchive:
remote_src: true
src: "{{ atl_product_download }}"
dest: "{{ atl_product_installation_versioned }}"
owner: "{{ atl_product_user }}"
group: "{{ atl_product_user }}"
mode: 0755
# Strip off the lead product/version specific directory to normaise naming
extra_opts:
- "--strip-components=1"
# NOTE: Currently all products contain a `README.txt`, so use that as an 'unpacked' marker.
creates: "{{ atl_product_installation_versioned }}/README.txt"