resolving conflicts

This commit is contained in:
Azra Sulthana
2019-07-15 04:15:31 +00:00
15 changed files with 203 additions and 7 deletions

View File

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

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,20 @@
---
dependency:
name: galaxy
driver:
name: docker
lint:
name: yamllint
platforms:
- name: amazon_linux2
image: amazonlinux:2
- name: ubuntu_lts
image: ubuntu:bionic
provisioner:
name: ansible
lint:
name: ansible-lint
verifier:
name: testinfra
lint:
name: flake8

View File

@@ -0,0 +1,14 @@
---
- name: Converge
hosts: all
vars:
atl_product_user: "testuser"
atl_product_home: "/opt/atlassian/product"
atl_product_installation_base: "/opt/atlassian/product/install"
atl_installer_temp: "/opt/atlassian/temp"
atl_product_home_shared: "/media/atl/jira/shared"
atl_product_shared_plugins: "/media/atl/jira/shared/plugins/"
atl_use_system_jdk: true
roles:
- role: linux_common
- role: product_common

View File

@@ -0,0 +1,20 @@
import os
import pytest
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
def test_user_created(host):
user = host.user('testuser')
assert user.exists
@pytest.mark.parametrize('exe', [
'/usr/bin/git',
'/usr/bin/javac'
])
def test_package_exes(host, exe):
assert host.file(exe).exists

View File

@@ -4,7 +4,7 @@
yum:
name:
- java-{{ java_version }}-openjdk-devel
when: use_system_jdk
when: atl_use_system_jdk
- name: Install other base packages on Amazon Linux
yum:

View File

@@ -4,7 +4,7 @@
package:
name:
- openjdk-{{ java_major_version }}-jdk-headless
when: use_system_jdk
when: atl_use_system_jdk
tags:
- runtime_pkg

View File

@@ -8,13 +8,19 @@ 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_download_suffix: "{{ atl_download_format_suffix_map[atl_download_format] }}"
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_crowd_download_url: "{{ atl_product_base_url }}/atlassian-{{ atl_download_edition | default(atl_product_edition) }}-{{ atl_product_version }}.tar.gz"
atl_crowd_latest_url: "https://www.atlassian.com/software/crowd/downloads/binary/crowd-standalone-distribution-{{atl_latest_version}}.tar.gz"
#atl_crowd_download_url: "{{ atl_product_base_url }}/atlassian-{{ atl_download_edition | default(atl_product_edition) }}-{{ atl_product_version }}.tar.gz"
#atl_crowd_latest_url: "https://www.atlassian.com/software/crowd/downloads/binary/crowd-standalone-distribution-{{atl_latest_version}}.tar.gz"
atl_product_download_url: "{{ atl_product_base_url }}/atlassian-{{ atl_download_edition | default(atl_product_edition) }}-{{ atl_product_version }}{{ atl_download_suffix }}"
atl_product_download_filename: "{{ atl_download_edition | default(atl_product_edition) }}.{{ atl_product_version }}.bin"
atl_product_download_filename: "{{ atl_download_edition | default(atl_product_edition) }}.{{ atl_product_version }}{{ atl_download_suffix }}"
atl_product_download: "{{ atl_installer_temp }}/{{ atl_product_download_filename }}"
atl_product_varfile: "{{ atl_installer_temp }}/{{ atl_product_family }}.varfile"

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+'.tar.gz')
assert installer.exists
assert installer.user == 'root'

View File

@@ -159,6 +159,9 @@
- import_tasks: crowd_install.yml
when: atl_product_edition == "crowd"
- name: Unpack the downloaded application depending on format
include_tasks: "unpack_{{ atl_download_format }}.yml"
- name: Symlink the installed version to current
file:
src: "{{ atl_product_installation_versioned }}"

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 normalise 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"