From 4dff688b3d3d7c9d22af1748afe493e9e1387482 Mon Sep 17 00:00:00 2001 From: Steve Smith Date: Thu, 11 Jul 2019 13:57:38 +1000 Subject: [PATCH] DCD-484: Rename use_system_jdk to match the other vars. --- roles/product_common/defaults/main.yml | 2 +- .../molecule/system_jdk/Dockerfile.j2 | 14 +++++++++++++ .../molecule/system_jdk/molecule.yml | 20 +++++++++++++++++++ .../molecule/system_jdk/playbook.yml | 14 +++++++++++++ .../molecule/system_jdk/tests/test_default.py | 20 +++++++++++++++++++ roles/product_common/tasks/amazon.yml | 2 +- roles/product_common/tasks/ubuntu.yml | 2 +- 7 files changed, 71 insertions(+), 3 deletions(-) create mode 100644 roles/product_common/molecule/system_jdk/Dockerfile.j2 create mode 100644 roles/product_common/molecule/system_jdk/molecule.yml create mode 100644 roles/product_common/molecule/system_jdk/playbook.yml create mode 100644 roles/product_common/molecule/system_jdk/tests/test_default.py diff --git a/roles/product_common/defaults/main.yml b/roles/product_common/defaults/main.yml index 70c4ee2..cb807b0 100644 --- a/roles/product_common/defaults/main.yml +++ b/roles/product_common/defaults/main.yml @@ -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 diff --git a/roles/product_common/molecule/system_jdk/Dockerfile.j2 b/roles/product_common/molecule/system_jdk/Dockerfile.j2 new file mode 100644 index 0000000..e6aa95d --- /dev/null +++ b/roles/product_common/molecule/system_jdk/Dockerfile.j2 @@ -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 diff --git a/roles/product_common/molecule/system_jdk/molecule.yml b/roles/product_common/molecule/system_jdk/molecule.yml new file mode 100644 index 0000000..c6a6d26 --- /dev/null +++ b/roles/product_common/molecule/system_jdk/molecule.yml @@ -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 diff --git a/roles/product_common/molecule/system_jdk/playbook.yml b/roles/product_common/molecule/system_jdk/playbook.yml new file mode 100644 index 0000000..8fec31a --- /dev/null +++ b/roles/product_common/molecule/system_jdk/playbook.yml @@ -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 diff --git a/roles/product_common/molecule/system_jdk/tests/test_default.py b/roles/product_common/molecule/system_jdk/tests/test_default.py new file mode 100644 index 0000000..77d3c52 --- /dev/null +++ b/roles/product_common/molecule/system_jdk/tests/test_default.py @@ -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 diff --git a/roles/product_common/tasks/amazon.yml b/roles/product_common/tasks/amazon.yml index c34c322..c02f864 100644 --- a/roles/product_common/tasks/amazon.yml +++ b/roles/product_common/tasks/amazon.yml @@ -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: diff --git a/roles/product_common/tasks/ubuntu.yml b/roles/product_common/tasks/ubuntu.yml index 68a20ff..55c6311 100644 --- a/roles/product_common/tasks/ubuntu.yml +++ b/roles/product_common/tasks/ubuntu.yml @@ -4,7 +4,7 @@ package: name: - openjdk-{{ java_major_version }}-jdk-headless - when: use_system_jdk + when: atl_use_system_jdk tags: - runtime_pkg