DCD-224: Rename jira_download to product_download.

This commit is contained in:
Steve Smith
2019-04-24 11:29:13 +10:00
parent 882ef9b2a8
commit 73fbdf4695
23 changed files with 6 additions and 6 deletions

View File

@@ -0,0 +1,11 @@
extends: default
rules:
braces:
max-spaces-inside: 1
level: error
brackets:
max-spaces-inside: 1
level: error
line-length: disable
truthy: disable

View File

@@ -0,0 +1,10 @@
---
atl_product_latest_version_url: "https://marketplace.atlassian.com/rest/2/applications/{{ atl_product_family }}/versions/latest"
atl_product_version_cache: "{{ atl_product_home_shared }}/{{ atl_product_edition }}.version"
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_product_edition }}-{{ atl_product_version_file.stdout }}.tar.gz"
atl_product_download_filename: "{{ atl_product_edition }}.{{ atl_product_version_file.stdout }}.tar.gz"
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,11 @@
---
- name: Converge
hosts: all
vars:
atl_product_family: "jira"
atl_product_edition: "jira-software"
atl_product_user: "jira"
roles:
- role: linux_common
- role: product_common
- role: product_download

View File

@@ -0,0 +1,25 @@
import os
import urllib.request
import testinfra.utils.ansible_runner
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-software.version')
assert verfile.exists
upstream_fd = urllib.request.urlopen("https://s3.amazonaws.com/atlassian-software/releases/jira-software/latest")
upstream = upstream_fd.read()
assert verfile.content.decode("UTF-8").strip() == upstream.decode("UTF-8").strip()
def test_latest_is_downloaded(host):
upstream_fd = urllib.request.urlopen("https://s3.amazonaws.com/atlassian-software/releases/jira-software/latest")
upstream = upstream_fd.read().decode("UTF-8").strip()
installer = host.file('/opt/atlassian/tmp/jira-software.'+upstream+'.tar.gz')
assert installer.exists
assert installer.user == 'root'

View File

@@ -0,0 +1,21 @@
import os
import urllib.request
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
def test_version_downloaded(host):
verfile = host.file('/media/atl/jira/shared/jira-software.version')
assert verfile.exists
def test_symlink_created(host):
target = host.file('/opt/atlassian/jira-software/current')
assert target.exists
assert target.is_symlink
def test_unpacked(host):
verfile = host.file('/opt/atlassian/jira-software/current/bin/catalina.sh')
assert verfile.exists

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,22 @@
---
- name: Converge
hosts: all
vars:
atl_product_family: "jira"
atl_product_edition: "jira-software"
atl_product_user: "jira"
pre_tasks:
- name: Create cache dir
file:
path: '/media/atl/jira/shared/'
state: directory
- name: Seed version
copy:
dest: '/media/atl/jira/shared/jira-software.version'
content: "7.9.0"
roles:
- role: linux_common
- role: product_common
- role: product_download

View File

@@ -0,0 +1,26 @@
import os
import urllib.request
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
def test_version_is_correct(host):
verfile = host.file('/media/atl/jira/shared/jira-software.version')
assert verfile.exists
assert verfile.content.decode("UTF-8").strip() == "7.9.0"
def test_is_downloaded(host):
installer = host.file('/opt/atlassian/tmp/jira-software.7.9.0.tar.gz')
assert installer.exists
assert installer.user == 'root'
def test_is_unpacked(host):
installer = host.file('/opt/atlassian/jira-software/7.9.0')
assert installer.exists
assert installer.is_directory
assert installer.user == 'jira'
assert installer.mode == 0o0755

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-software"
atl_product_user: "jira"
atl_product_version: "latest"
roles:
- role: linux_common
- role: product_common
- role: product_download

View File

@@ -0,0 +1,25 @@
import os
import urllib.request
import testinfra.utils.ansible_runner
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-software.version')
assert verfile.exists
upstream_fd = urllib.request.urlopen("https://s3.amazonaws.com/atlassian-software/releases/jira-software/latest")
upstream = upstream_fd.read()
assert verfile.content.decode("UTF-8").strip() == upstream.decode("UTF-8").strip()
def test_latest_is_downloaded(host):
upstream_fd = urllib.request.urlopen("https://s3.amazonaws.com/atlassian-software/releases/jira-software/latest")
upstream = upstream_fd.read().decode("UTF-8").strip()
installer = host.file('/opt/atlassian/tmp/jira-software.'+upstream+'.tar.gz')
assert installer.exists
assert installer.user == 'root'

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-software"
atl_product_user: "jira"
atl_product_version: "7.13.2"
roles:
- role: linux_common
- role: product_common
- role: product_download

View File

@@ -0,0 +1,26 @@
import os
import urllib.request
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
def test_version_is_correct(host):
verfile = host.file('/media/atl/jira/shared/jira-software.version')
assert verfile.exists
assert verfile.content.decode("UTF-8").strip() == "7.13.2"
def test_is_downloaded(host):
installer = host.file('/opt/atlassian/tmp/jira-software.7.13.2.tar.gz')
assert installer.exists
assert installer.user == 'root'
def test_is_unpacked(host):
installer = host.file('/opt/atlassian/jira-software/7.13.2')
assert installer.exists
assert installer.is_directory
assert installer.user == 'jira'
assert installer.mode == 0o0755

View File

@@ -0,0 +1,59 @@
---
- name: Fetch and cache latest version when no override
block:
- name: Fetch the latest version from URL
set_fact:
atl_product_version_json: "{{ lookup('url', '{{ atl_product_latest_version_url }}') }}"
- name: Set the local var to fetched version
set_fact:
atl_product_version: "{{ atl_product_version_json.version }}"
when: atl_product_version is undefined or atl_product_version == "latest"
- name: Write override cached version when specified
template:
src: version.j2
dest: "{{ atl_product_version_cache }}"
force: false
- name: Use version for product version
command: "cat {{ atl_product_version_cache }}"
register: atl_product_version_file
changed_when: false
# Note: We don't cache this in the shared drive to the complexity
# around download race-conditions if multiple nodes are starting at
# the same time. When downloading from product-downloads.atlassian.com
# (which is a CDN) takes seconds anyway.
- name: Fetch product installer
get_url:
url: "{{ atl_product_download_url }}"
dest: "{{ atl_product_download }}"
mode: 0644
force: false
- name: Create target version directory
file:
path: "{{ atl_product_installation_base }}/{{ atl_product_version_file.stdout }}"
state: directory
owner: "{{ atl_product_user }}"
- name: Unpack the product packages
unarchive:
remote_src: true
src: "{{ atl_product_download }}"
dest: "{{ atl_product_installation_base }}/{{ atl_product_version_file.stdout }}"
creates: "{{ atl_product_installation_base }}/{{ atl_product_version_file.stdout }}/bin/catalina.sh"
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"
- name: Symlink the installed version to current
file:
src: "{{ atl_product_installation_base }}/{{ atl_product_version_file.stdout }}"
dest: "{{ atl_product_installation_target }}"
state: link
force: true

View File

@@ -0,0 +1 @@
{{ atl_product_version }}