diff --git a/aws_jira_dc_node.yml b/aws_jira_dc_node.yml index da7fa7b..410de0e 100644 --- a/aws_jira_dc_node.yml +++ b/aws_jira_dc_node.yml @@ -12,7 +12,7 @@ - role: aws_common - role: aws_efs_config - role: product_common - - role: tgz_download + - role: installer_download - role: database_config - role: jira_config - role: jira_startup diff --git a/group_vars/aws_node_local.yml b/group_vars/aws_node_local.yml index 18b9c3a..a69c57c 100644 --- a/group_vars/aws_node_local.yml +++ b/group_vars/aws_node_local.yml @@ -22,7 +22,8 @@ atl_product_shared_plugins: "{{ atl_product_home_shared }}/plugins/installed-plu atl_installation_base: "/opt/atlassian" atl_product_installation_base: "{{ atl_installation_base }}/{{ atl_product_edition }}" -atl_product_installation_target: "{{ atl_installation_base }}/{{ atl_product_edition }}/current" +atl_product_installation_versioned: "{{ atl_product_installation_base }}/{{ atl_product_version }}" +atl_product_installation_current: "{{ atl_product_installation_base }}/current" atl_installer_temp: "{{ atl_installation_base }}/tmp" diff --git a/roles/installer_download/.yamllint b/roles/installer_download/.yamllint new file mode 100644 index 0000000..a87f8ff --- /dev/null +++ b/roles/installer_download/.yamllint @@ -0,0 +1,12 @@ +extends: default + +rules: + braces: + max-spaces-inside: 1 + level: error + brackets: + max-spaces-inside: 1 + level: error + line-length: disable + truthy: disable + trailing-spaces: false diff --git a/roles/installer_download/defaults/main.yml b/roles/installer_download/defaults/main.yml new file mode 100644 index 0000000..60e2896 --- /dev/null +++ b/roles/installer_download/defaults/main.yml @@ -0,0 +1,22 @@ +--- + +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_download_edition | default(atl_product_edition) }}-{{ atl_download_version | default(atl_product_version) }}-x64.bin" + +atl_product_download_filename: "{{ atl_download_edition | default(atl_product_edition) }}.{{ atl_download_version | default(atl_product_version) }}.bin" +atl_product_download: "{{ atl_installer_temp }}/{{ atl_product_download_filename }}" +atl_product_varfile: "{{ atl_installer_temp }}/{{ atl_product_family }}.varfile" + +atl_marketplace_base: "https://marketplace.atlassian.com" +atl_servicedesk_latest_url: "https://marketplace.atlassian.com/rest/2/products/key/jira-servicedesk/versions/latest" +atl_servicedesk_versioned_url: "https://marketplace.atlassian.com/rest/2/products/key/jira-servicedesk/versions/name/{{ atl_product_version }}" +atl_servicedesk_url_map: + latest: "{{ atl_servicedesk_latest_url }}" + default: "{{ atl_servicedesk_versioned_url }}" +atl_servicedesk_metadata_url: "{{ atl_servicedesk_url_map[atl_product_version] | default(atl_servicedesk_url_map['default']) }}" + +atl_servicedesk_download_file: "{{ atl_installer_temp }}/jira-servicedesk.{{ atl_product_version }}.obr" diff --git a/roles/installer_download/molecule/bitbucket_latest/Dockerfile.j2 b/roles/installer_download/molecule/bitbucket_latest/Dockerfile.j2 new file mode 100644 index 0000000..e6aa95d --- /dev/null +++ b/roles/installer_download/molecule/bitbucket_latest/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/installer_download/molecule/bitbucket_latest/molecule.yml b/roles/installer_download/molecule/bitbucket_latest/molecule.yml new file mode 100644 index 0000000..7fd3163 --- /dev/null +++ b/roles/installer_download/molecule/bitbucket_latest/molecule.yml @@ -0,0 +1,30 @@ +--- +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 + lint: + name: flake8 + enabled: false diff --git a/roles/installer_download/molecule/bitbucket_latest/playbook.yml b/roles/installer_download/molecule/bitbucket_latest/playbook.yml new file mode 100644 index 0000000..43bb7cf --- /dev/null +++ b/roles/installer_download/molecule/bitbucket_latest/playbook.yml @@ -0,0 +1,11 @@ +--- +- name: Converge + hosts: all + vars: + atl_product_family: "stash" + atl_product_edition: "bitbucket" + atl_product_user: "bitbucket" + roles: + - role: linux_common + - role: product_common + - role: installer_download diff --git a/roles/installer_download/molecule/bitbucket_latest/tests/#test_default.py# b/roles/installer_download/molecule/bitbucket_latest/tests/#test_default.py# new file mode 100644 index 0000000..0862a21 --- /dev/null +++ b/roles/installer_download/molecule/bitbucket_latest/tests/#test_default.py# @@ -0,0 +1,43 @@ +import os +import urllib.request +import json + +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/confluence/shared/confluence.version') + assert verfile.exists + +def test_symlink_created(host): + target = host.file('/opt/atlassian/confluence/current') + assert target.exists + assert target.is_symlink + +def test_unpacked(host): + verfile = host.file('/opt/atlassian/confluence/current/bin/catalina.sh') + assert verfile.exists + +def test_version_file_is_latest(host): + verfile = host.file('/media/atl/confluence/shared/confluence.version') + assert verfile.exists + + upstream_fd = urllib.request.urlopen("https://marketplace.atlassian.com/rest/2/applications/confluence/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/confluence/versions/latest") + upstream_json = json.load(upstream_fd) + upstream = upstream_json['version'] + + installer = host.file('/opt/atlassian/tmp/confluence.'+upstream+'.tar.gz') + assert installer.exists + assert installer.user == 'root' + +https://product-downloads.atlassian.com/software/bitbucket/downloads/atlassian-bitbucket-6.2.0.tar.gz +https://product-downloads.atlassian.com/software/stash/downloads/atlassian-bitbucket-6.2.0.tar.gz \ No newline at end of file diff --git a/roles/installer_download/molecule/bitbucket_latest/tests/test_default.py b/roles/installer_download/molecule/bitbucket_latest/tests/test_default.py new file mode 100644 index 0000000..18e4662 --- /dev/null +++ b/roles/installer_download/molecule/bitbucket_latest/tests/test_default.py @@ -0,0 +1,40 @@ +import os +import urllib.request +import json + +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/stash/shared/bitbucket.version') + assert verfile.exists + +def test_symlink_created(host): + target = host.file('/opt/atlassian/bitbucket/current') + assert target.exists + assert target.is_symlink + +def test_unpacked(host): + verfile = host.file('/opt/atlassian/bitbucket/current/bin/start-bitbucket.sh') + assert verfile.exists + +def test_version_file_is_latest(host): + verfile = host.file('/media/atl/stash/shared/bitbucket.version') + assert verfile.exists + + upstream_fd = urllib.request.urlopen("https://marketplace.atlassian.com/rest/2/applications/bitbucket/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/bitbucket/versions/latest") + upstream_json = json.load(upstream_fd) + upstream = upstream_json['version'] + + installer = host.file('/opt/atlassian/tmp/bitbucket.'+upstream+'.bin') + assert installer.exists + assert installer.user == 'root' diff --git a/roles/installer_download/molecule/confluence_latest/Dockerfile.j2 b/roles/installer_download/molecule/confluence_latest/Dockerfile.j2 new file mode 100644 index 0000000..e6aa95d --- /dev/null +++ b/roles/installer_download/molecule/confluence_latest/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/installer_download/molecule/confluence_latest/molecule.yml b/roles/installer_download/molecule/confluence_latest/molecule.yml new file mode 100644 index 0000000..7fd3163 --- /dev/null +++ b/roles/installer_download/molecule/confluence_latest/molecule.yml @@ -0,0 +1,30 @@ +--- +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 + lint: + name: flake8 + enabled: false diff --git a/roles/installer_download/molecule/confluence_latest/playbook.yml b/roles/installer_download/molecule/confluence_latest/playbook.yml new file mode 100644 index 0000000..6827228 --- /dev/null +++ b/roles/installer_download/molecule/confluence_latest/playbook.yml @@ -0,0 +1,11 @@ +--- +- name: Converge + hosts: all + vars: + atl_product_family: "confluence" + atl_product_edition: "confluence" + atl_product_user: "confluence" + roles: + - role: linux_common + - role: product_common + - role: installer_download diff --git a/roles/installer_download/molecule/confluence_latest/tests/test_default.py b/roles/installer_download/molecule/confluence_latest/tests/test_default.py new file mode 100644 index 0000000..b67d8ec --- /dev/null +++ b/roles/installer_download/molecule/confluence_latest/tests/test_default.py @@ -0,0 +1,40 @@ +import os +import urllib.request +import json + +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/confluence/shared/confluence.version') + assert verfile.exists + +def test_symlink_created(host): + target = host.file('/opt/atlassian/confluence/current') + assert target.exists + assert target.is_symlink + +def test_unpacked(host): + verfile = host.file('/opt/atlassian/confluence/current/bin/catalina.sh') + assert verfile.exists + +def test_version_file_is_latest(host): + verfile = host.file('/media/atl/confluence/shared/confluence.version') + assert verfile.exists + + upstream_fd = urllib.request.urlopen("https://marketplace.atlassian.com/rest/2/applications/confluence/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/confluence/versions/latest") + upstream_json = json.load(upstream_fd) + upstream = upstream_json['version'] + + installer = host.file('/opt/atlassian/tmp/confluence.'+upstream+'.bin') + assert installer.exists + assert installer.user == 'root' diff --git a/roles/installer_download/molecule/default/Dockerfile.j2 b/roles/installer_download/molecule/default/Dockerfile.j2 new file mode 100644 index 0000000..e6aa95d --- /dev/null +++ b/roles/installer_download/molecule/default/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/installer_download/molecule/default/molecule.yml b/roles/installer_download/molecule/default/molecule.yml new file mode 100644 index 0000000..46049f8 --- /dev/null +++ b/roles/installer_download/molecule/default/molecule.yml @@ -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 diff --git a/roles/installer_download/molecule/default/playbook.yml b/roles/installer_download/molecule/default/playbook.yml new file mode 100644 index 0000000..67e1197 --- /dev/null +++ b/roles/installer_download/molecule/default/playbook.yml @@ -0,0 +1,11 @@ +--- +- name: Converge + hosts: all + vars: + atl_product_family: "jira" + atl_product_edition: "jira-core" + atl_product_user: "jira" + roles: + - role: linux_common + - role: product_common + - role: installer_download diff --git a/roles/installer_download/molecule/default/tests/test_default.py b/roles/installer_download/molecule/default/tests/test_default.py new file mode 100644 index 0000000..dc659f1 --- /dev/null +++ b/roles/installer_download/molecule/default/tests/test_default.py @@ -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-core.version') + assert verfile.exists + + upstream_fd = urllib.request.urlopen("https://s3.amazonaws.com/atlassian-software/releases/jira-core/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-core/latest") + upstream = upstream_fd.read().decode("UTF-8").strip() + + installer = host.file('/opt/atlassian/tmp/jira-core.'+upstream+'.bin') + assert installer.exists + assert installer.user == 'root' diff --git a/roles/installer_download/molecule/jira_version_from_file/Dockerfile.j2 b/roles/installer_download/molecule/jira_version_from_file/Dockerfile.j2 new file mode 100644 index 0000000..e6aa95d --- /dev/null +++ b/roles/installer_download/molecule/jira_version_from_file/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/installer_download/molecule/jira_version_from_file/molecule.yml b/roles/installer_download/molecule/jira_version_from_file/molecule.yml new file mode 100644 index 0000000..46049f8 --- /dev/null +++ b/roles/installer_download/molecule/jira_version_from_file/molecule.yml @@ -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 diff --git a/roles/installer_download/molecule/jira_version_from_file/playbook.yml b/roles/installer_download/molecule/jira_version_from_file/playbook.yml new file mode 100644 index 0000000..0782261 --- /dev/null +++ b/roles/installer_download/molecule/jira_version_from_file/playbook.yml @@ -0,0 +1,24 @@ +--- +- name: Converge + hosts: all + vars: + atl_product_family: "jira" + atl_product_edition: "jira-core" + atl_product_user: "jira" + # NOTE: This should be ignored because the version file exists. + atl_product_version: "latest" + + pre_tasks: + - name: Create cache dir + file: + path: '/media/atl/jira/shared/' + state: directory + - name: Seed version + copy: + dest: '/media/atl/jira/shared/jira-core.version' + content: "7.9.0" + + roles: + - role: linux_common + - role: product_common + - role: installer_download diff --git a/roles/installer_download/molecule/jira_version_from_file/tests/test_default.py b/roles/installer_download/molecule/jira_version_from_file/tests/test_default.py new file mode 100644 index 0000000..4ba5091 --- /dev/null +++ b/roles/installer_download/molecule/jira_version_from_file/tests/test_default.py @@ -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-core.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-core.7.9.0.bin') + assert installer.exists + assert installer.user == 'root' + +def test_is_unpacked(host): + installer = host.file('/opt/atlassian/jira-core/7.9.0') + assert installer.exists + assert installer.is_directory + assert installer.user == 'jira' + assert installer.mode == 0o0755 diff --git a/roles/installer_download/molecule/jira_version_latest/Dockerfile.j2 b/roles/installer_download/molecule/jira_version_latest/Dockerfile.j2 new file mode 100644 index 0000000..e6aa95d --- /dev/null +++ b/roles/installer_download/molecule/jira_version_latest/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/installer_download/molecule/jira_version_latest/molecule.yml b/roles/installer_download/molecule/jira_version_latest/molecule.yml new file mode 100644 index 0000000..46049f8 --- /dev/null +++ b/roles/installer_download/molecule/jira_version_latest/molecule.yml @@ -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 diff --git a/roles/installer_download/molecule/jira_version_latest/playbook.yml b/roles/installer_download/molecule/jira_version_latest/playbook.yml new file mode 100644 index 0000000..7e0728c --- /dev/null +++ b/roles/installer_download/molecule/jira_version_latest/playbook.yml @@ -0,0 +1,12 @@ +--- +- name: Converge + hosts: all + vars: + atl_product_family: "jira" + atl_product_edition: "jira-core" + atl_product_user: "jira" + atl_product_version: "latest" + roles: + - role: linux_common + - role: product_common + - role: installer_download diff --git a/roles/installer_download/molecule/jira_version_latest/tests/test_default.py b/roles/installer_download/molecule/jira_version_latest/tests/test_default.py new file mode 100644 index 0000000..dc659f1 --- /dev/null +++ b/roles/installer_download/molecule/jira_version_latest/tests/test_default.py @@ -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-core.version') + assert verfile.exists + + upstream_fd = urllib.request.urlopen("https://s3.amazonaws.com/atlassian-software/releases/jira-core/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-core/latest") + upstream = upstream_fd.read().decode("UTF-8").strip() + + installer = host.file('/opt/atlassian/tmp/jira-core.'+upstream+'.bin') + assert installer.exists + assert installer.user == 'root' diff --git a/roles/installer_download/molecule/jira_version_override/Dockerfile.j2 b/roles/installer_download/molecule/jira_version_override/Dockerfile.j2 new file mode 100644 index 0000000..e6aa95d --- /dev/null +++ b/roles/installer_download/molecule/jira_version_override/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/installer_download/molecule/jira_version_override/molecule.yml b/roles/installer_download/molecule/jira_version_override/molecule.yml new file mode 100644 index 0000000..46049f8 --- /dev/null +++ b/roles/installer_download/molecule/jira_version_override/molecule.yml @@ -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 diff --git a/roles/installer_download/molecule/jira_version_override/playbook.yml b/roles/installer_download/molecule/jira_version_override/playbook.yml new file mode 100644 index 0000000..fa175b7 --- /dev/null +++ b/roles/installer_download/molecule/jira_version_override/playbook.yml @@ -0,0 +1,12 @@ +--- +- name: Converge + hosts: all + vars: + atl_product_family: "jira" + atl_product_edition: "jira-core" + atl_product_user: "jira" + atl_product_version: "7.13.2" + roles: + - role: linux_common + - role: product_common + - role: installer_download diff --git a/roles/installer_download/molecule/jira_version_override/tests/test_default.py b/roles/installer_download/molecule/jira_version_override/tests/test_default.py new file mode 100644 index 0000000..4c9149c --- /dev/null +++ b/roles/installer_download/molecule/jira_version_override/tests/test_default.py @@ -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-core.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-core.7.13.2.bin') + assert installer.exists + assert installer.user == 'root' + +def test_is_unpacked(host): + installer = host.file('/opt/atlassian/jira-core/7.13.2') + assert installer.exists + assert installer.is_directory + assert installer.user == 'jira' + assert installer.mode == 0o0755 diff --git a/roles/installer_download/molecule/resources/tests/test_common.py b/roles/installer_download/molecule/resources/tests/test_common.py new file mode 100644 index 0000000..bb85871 --- /dev/null +++ b/roles/installer_download/molecule/resources/tests/test_common.py @@ -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-core.version') + assert verfile.exists + +def test_symlink_created(host): + target = host.file('/opt/atlassian/jira-core/current') + assert target.exists + assert target.is_symlink + +def test_unpacked(host): + verfile = host.file('/opt/atlassian/jira-core/current/bin/catalina.sh') + assert verfile.exists diff --git a/roles/installer_download/molecule/servicedesk3/Dockerfile.j2 b/roles/installer_download/molecule/servicedesk3/Dockerfile.j2 new file mode 100644 index 0000000..e6aa95d --- /dev/null +++ b/roles/installer_download/molecule/servicedesk3/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/installer_download/molecule/servicedesk3/molecule.yml b/roles/installer_download/molecule/servicedesk3/molecule.yml new file mode 100644 index 0000000..52ea9de --- /dev/null +++ b/roles/installer_download/molecule/servicedesk3/molecule.yml @@ -0,0 +1,31 @@ +--- +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: + vv: true + skip-tags: runtime_pkg + lint: + name: ansible-lint + inventory: + links: + group_vars: ../../../../group_vars/ +verifier: + name: testinfra + lint: + name: flake8 + enabled: false diff --git a/roles/installer_download/molecule/servicedesk3/playbook.yml b/roles/installer_download/molecule/servicedesk3/playbook.yml new file mode 100644 index 0000000..172dc4b --- /dev/null +++ b/roles/installer_download/molecule/servicedesk3/playbook.yml @@ -0,0 +1,13 @@ +--- +- name: Converge + hosts: all + vars: + atl_product_edition: "jira-servicedesk" + atl_product_family: "jira" + atl_product_user: "jira" + atl_product_version: "3.9.0" + + roles: + - role: linux_common + - role: product_common + - role: installer_download diff --git a/roles/installer_download/molecule/servicedesk3/tests/test_default.py b/roles/installer_download/molecule/servicedesk3/tests/test_default.py new file mode 100644 index 0000000..280bdee --- /dev/null +++ b/roles/installer_download/molecule/servicedesk3/tests/test_default.py @@ -0,0 +1,37 @@ +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-servicedesk.version') + assert verfile.exists + + assert verfile.content.decode("UTF-8").strip() == "3.0.2" + +def test_is_downloaded(host): + installer = host.file('/opt/atlassian/tmp/jira-software.7.0.11.tar.gz') + assert installer.exists + assert installer.user == 'root' + +def test_is_unpacked(host): + installer = host.file('/opt/atlassian/jira-servicedesk/3.0.2') + assert installer.exists + assert installer.is_directory + assert installer.user == 'jira' + assert installer.mode == 0o0755 + +def test_sd_is_downloaded(host): + installer = host.file('/opt/atlassian/tmp/jira-servicedesk.3.0.2.obr') + 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.user == 'jira' + assert installer.mode == 0o0750 diff --git a/roles/installer_download/molecule/servicedesk4/Dockerfile.j2 b/roles/installer_download/molecule/servicedesk4/Dockerfile.j2 new file mode 100644 index 0000000..e6aa95d --- /dev/null +++ b/roles/installer_download/molecule/servicedesk4/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/installer_download/molecule/servicedesk4/molecule.yml b/roles/installer_download/molecule/servicedesk4/molecule.yml new file mode 100644 index 0000000..52ea9de --- /dev/null +++ b/roles/installer_download/molecule/servicedesk4/molecule.yml @@ -0,0 +1,31 @@ +--- +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: + vv: true + skip-tags: runtime_pkg + lint: + name: ansible-lint + inventory: + links: + group_vars: ../../../../group_vars/ +verifier: + name: testinfra + lint: + name: flake8 + enabled: false diff --git a/roles/installer_download/molecule/servicedesk4/playbook.yml b/roles/installer_download/molecule/servicedesk4/playbook.yml new file mode 100644 index 0000000..64c8c85 --- /dev/null +++ b/roles/installer_download/molecule/servicedesk4/playbook.yml @@ -0,0 +1,13 @@ +--- +- name: Converge + hosts: all + vars: + atl_product_edition: "jira-servicedesk" + atl_product_family: "jira" + atl_product_user: "jira" + atl_product_version: "4.1.0" + + roles: + - role: linux_common + - role: product_common + - role: installer_download diff --git a/roles/installer_download/molecule/servicedesk4/tests/test_default.py b/roles/installer_download/molecule/servicedesk4/tests/test_default.py new file mode 100644 index 0000000..4b86875 --- /dev/null +++ b/roles/installer_download/molecule/servicedesk4/tests/test_default.py @@ -0,0 +1,37 @@ +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-servicedesk.version') + assert verfile.exists + + assert verfile.content.decode("UTF-8").strip() == "4.1.0" + +def test_is_downloaded(host): + installer = host.file('/opt/atlassian/tmp/jira-software.8.1.0.tar.gz') + assert installer.exists + assert installer.user == 'root' + +def test_is_unpacked(host): + installer = host.file('/opt/atlassian/jira-servicedesk/4.1.0') + assert installer.exists + assert installer.is_directory + assert installer.user == 'jira' + assert installer.mode == 0o0755 + +def test_sd_is_downloaded(host): + installer = host.file('/opt/atlassian/tmp/jira-servicedesk.4.1.0.obr') + 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.user == 'jira' + assert installer.mode == 0o0750 diff --git a/roles/installer_download/molecule/servicedesk_latest/Dockerfile.j2 b/roles/installer_download/molecule/servicedesk_latest/Dockerfile.j2 new file mode 100644 index 0000000..e6aa95d --- /dev/null +++ b/roles/installer_download/molecule/servicedesk_latest/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/installer_download/molecule/servicedesk_latest/molecule.yml b/roles/installer_download/molecule/servicedesk_latest/molecule.yml new file mode 100644 index 0000000..52ea9de --- /dev/null +++ b/roles/installer_download/molecule/servicedesk_latest/molecule.yml @@ -0,0 +1,31 @@ +--- +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: + vv: true + skip-tags: runtime_pkg + lint: + name: ansible-lint + inventory: + links: + group_vars: ../../../../group_vars/ +verifier: + name: testinfra + lint: + name: flake8 + enabled: false diff --git a/roles/installer_download/molecule/servicedesk_latest/playbook.yml b/roles/installer_download/molecule/servicedesk_latest/playbook.yml new file mode 100644 index 0000000..38a132a --- /dev/null +++ b/roles/installer_download/molecule/servicedesk_latest/playbook.yml @@ -0,0 +1,13 @@ +--- +- name: Converge + hosts: all + vars: + atl_product_edition: "jira-servicedesk" + atl_product_family: "jira" + atl_product_user: "jira" + atl_product_version: "latest" + + roles: + - role: linux_common + - role: product_common + - role: installer_download diff --git a/roles/installer_download/molecule/servicedesk_latest/tests/test_default.py b/roles/installer_download/molecule/servicedesk_latest/tests/test_default.py new file mode 100644 index 0000000..6ff8e80 --- /dev/null +++ b/roles/installer_download/molecule/servicedesk_latest/tests/test_default.py @@ -0,0 +1,46 @@ +import os +import json +import urllib.request + +import testinfra.utils.ansible_runner + +testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') + +def get_latest(): + data = urllib.request.urlopen("https://marketplace.atlassian.com/rest/2/products/key/jira-servicedesk/versions/latest") + meta = json.loads(data.read().decode("UTF-8")) + servicedesk = meta['name'] + jira = meta['compatibilities'][0]['hosting']['server']['max']['version'] + return (servicedesk, jira) + +(sd, jira) = get_latest() + +def test_version_is_correct(host): + verfile = host.file('/media/atl/jira/shared/jira-servicedesk.version') + assert verfile.exists + + assert verfile.content.decode("UTF-8").strip() == sd + +def test_is_downloaded(host): + installer = host.file('/opt/atlassian/tmp/jira-software.'+jira+'.tar.gz') + assert installer.exists + assert installer.user == 'root' + +def test_is_unpacked(host): + installer = host.file('/opt/atlassian/jira-servicedesk/'+jira) + assert installer.exists + assert installer.is_directory + assert installer.user == 'jira' + assert installer.mode == 0o0755 + +def test_sd_is_downloaded(host): + installer = host.file('/opt/atlassian/tmp/jira-servicedesk.'+sd+'.obr') + 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.user == 'jira' + assert installer.mode == 0o0750 diff --git a/roles/installer_download/tasks/cached_version_fetch.yml b/roles/installer_download/tasks/cached_version_fetch.yml new file mode 100644 index 0000000..2df9c98 --- /dev/null +++ b/roles/installer_download/tasks/cached_version_fetch.yml @@ -0,0 +1,21 @@ +--- + +- name: Check for existing version cache file + stat: + path: "{{ atl_product_version_cache }}" + register: cached + +# Case: File exists, always use its value +- name: Use version for product version + block: + + - name: Read cached version from file + command: "cat {{ atl_product_version_cache }}" + register: atl_product_version_file + changed_when: false + + - name: Set the local var to cached version + set_fact: + atl_product_version: "{{ atl_product_version_file.stdout }}" + + when: cached.stat.exists diff --git a/roles/installer_download/tasks/cached_version_write.yml b/roles/installer_download/tasks/cached_version_write.yml new file mode 100644 index 0000000..3b93714 --- /dev/null +++ b/roles/installer_download/tasks/cached_version_write.yml @@ -0,0 +1,8 @@ +--- + +# At this point atl_product_version should be set, cache if necessary. +- name: Write override cached version when specified + template: + src: version.j2 + dest: "{{ atl_product_version_cache }}" + force: false diff --git a/roles/installer_download/tasks/fetch_product.yml b/roles/installer_download/tasks/fetch_product.yml new file mode 100644 index 0000000..b26a395 --- /dev/null +++ b/roles/installer_download/tasks/fetch_product.yml @@ -0,0 +1,29 @@ +--- + +# Note: We don't the cache binary 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: 0755 + force: false + +- name: Create installer varfile + template: + src: "{{ atl_product_family }}.varfile.j2" + dest: "{{ atl_product_varfile }}" + +- name: Run the installer + command: /bin/sh "{{ atl_product_download }}" -q -varfile "{{ atl_product_varfile }}" + args: + creates: "{{ atl_product_installation_versioned }}/.install4j/" + +- name: Symlink the installed version to current + file: + src: "{{ atl_product_installation_versioned }}" + dest: "{{ atl_product_installation_current }}" + state: link + force: true diff --git a/roles/installer_download/tasks/main.yml b/roles/installer_download/tasks/main.yml new file mode 100644 index 0000000..f3a5392 --- /dev/null +++ b/roles/installer_download/tasks/main.yml @@ -0,0 +1,23 @@ +--- + +- 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. +- name: Fetch ServiceDesk metadata if necessary + include_tasks: "servicedesk_download.yml" + when: atl_product_edition == "jira-servicedesk" + +# Differences for ServiceDesk become fiddly enough that it's better to +# just split them out and move common functionality into individual +# task files. +- name: Fetch product metadata if necessary + include_tasks: "product_download.yml" + when: atl_product_edition != "jira-servicedesk" diff --git a/roles/installer_download/tasks/product_download.yml b/roles/installer_download/tasks/product_download.yml new file mode 100644 index 0000000..87ce301 --- /dev/null +++ b/roles/installer_download/tasks/product_download.yml @@ -0,0 +1,31 @@ +--- + +- name: Check for and load cached version + include_tasks: "cached_version_fetch.yml" + + +# Case: File doesn't exist and no version has been set; find latest. +- 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 retrieved version + set_fact: + atl_product_version: "{{ atl_product_version_json.version }}" + + when: + not cached.stat.exists and + (atl_product_version is undefined or + not atl_product_version or + atl_product_version == "latest") + + +- name: Cache download version if necessary + include_tasks: "cached_version_write.yml" + + +- name: Fetch and unpack the product distribution + include_tasks: "fetch_product.yml" diff --git a/roles/installer_download/tasks/servicedesk_download.yml b/roles/installer_download/tasks/servicedesk_download.yml new file mode 100644 index 0000000..3572297 --- /dev/null +++ b/roles/installer_download/tasks/servicedesk_download.yml @@ -0,0 +1,34 @@ +--- + +- name: Check for and load cached version + include_tasks: "cached_version_fetch.yml" + + +# Case: File doesn't exist and no version has been set; find latest. +- name: Fetch and cache latest version when no override + block: + + - name: Fetch the ServiceDesk metadata from marketplace + set_fact: + atl_servicedesk_version_json: "{{ lookup('url', '{{ atl_servicedesk_latest_url }}') }}" + + - name: Set the Jira version for ServiceDesk + set_fact: + atl_product_version: "{{ atl_servicedesk_version_json.name }}" + + when: + not cached.stat.exists and + (atl_product_version is undefined or + not atl_product_version or + atl_product_version == "latest") + +- name: Cache download version if necessary + include_tasks: "cached_version_write.yml" + + +- name: Set the download edition for ServiceDesk + set_fact: + atl_download_edition: "servicedesk" + +- name: Fetch and unpack the product distribution + include_tasks: "fetch_product.yml" diff --git a/roles/installer_download/templates/confluence.varfile.j2 b/roles/installer_download/templates/confluence.varfile.j2 new file mode 100644 index 0000000..a06e485 --- /dev/null +++ b/roles/installer_download/templates/confluence.varfile.j2 @@ -0,0 +1,13 @@ +launch.application$Boolean=false +rmiPort$Long={{ atl_tomcat_mgmt_port | default('8005') }} +app.defaultHome={{ atl_product_home }} +app.install.service$Boolean=false +app.service.account={{ atl_product_user }} +existingInstallationDir={{ atl_product_installation_versioned }} +sys.confirmedUpdateInstallationString=false +sys.languageId=en +sys.installationDir={{ atl_product_installation_versioned }} +executeLauncherAction$Boolean=true +httpPort$Long={{ atl_tomcat_port | default('8080') }} +portChoice=default +executeLauncherAction$Boolean=false diff --git a/roles/installer_download/templates/jira.varfile.j2 b/roles/installer_download/templates/jira.varfile.j2 new file mode 100644 index 0000000..d1ad67d --- /dev/null +++ b/roles/installer_download/templates/jira.varfile.j2 @@ -0,0 +1,13 @@ +launch.application$Boolean=false +rmiPort$Long={{ atl_tomcat_mgmt_port | default('8005') }} +app.jiraHome={{ atl_product_home }} +app.install.service$Boolean=false +app.service.account={{ atl_product_user }} +existingInstallationDir={{ atl_product_installation_versioned }} +sys.confirmedUpdateInstallationString=false +sys.languageId=en +sys.installationDir={{ atl_product_installation_versioned }} +executeLauncherAction$Boolean=true +httpPort$Long={{ atl_tomcat_port | default('8080') }} +portChoice=default +executeLauncherAction$Boolean=false diff --git a/roles/installer_download/templates/stash.varfile.j2 b/roles/installer_download/templates/stash.varfile.j2 new file mode 100644 index 0000000..7858b71 --- /dev/null +++ b/roles/installer_download/templates/stash.varfile.j2 @@ -0,0 +1,10 @@ +app.install.service$Boolean=false +app.service.account={{ atl_product_user }} +portChoice=defaults +app.bitbucketHome={{ atl_product_home }} +app.defaultInstallDir={{ atl_product_installation_versioned }} +launch.application$Boolean=false +executeLauncherAction$Boolean=false +elasticsearch.install.service$Boolean={{ atl_bitbucket_bundled_elasticsearch_enabled | default('false') }} +confirm.disable.plugins$Boolean=true +container.configuration.ignore$Boolean=true diff --git a/roles/installer_download/templates/version.j2 b/roles/installer_download/templates/version.j2 new file mode 100644 index 0000000..7de6d7e --- /dev/null +++ b/roles/installer_download/templates/version.j2 @@ -0,0 +1 @@ +{{ atl_product_version }} diff --git a/roles/jira_config/tasks/main.yml b/roles/jira_config/tasks/main.yml index 96de31e..40b76f4 100644 --- a/roles/jira_config/tasks/main.yml +++ b/roles/jira_config/tasks/main.yml @@ -1,5 +1,6 @@ --- + - name: Create database config template: src: dbconfig.xml.j2 @@ -15,15 +16,27 @@ - name: Create server config template: src: server.xml.j2 - dest: "{{ atl_product_installation_target }}/conf/server.xml" + dest: "{{ atl_product_installation_versioned }}/conf/server.xml" - name: Override JVM memory settings. # Ugly but necessary as the product installs this file so we need to make the change here. lineinfile: - path: "{{ atl_product_installation_target }}/bin/setenv.sh" + path: "{{ atl_product_installation_versioned }}/bin/setenv.sh" backrefs: true regexp: "^{{ item }}=" line: "{{ item }}=\"{{ atl_jvm_heap }}\"" with_items: - 'JVM_MINIMUM_MEMORY' - 'JVM_MAXIMUM_MEMORY' + + +- name: Create application directories + file: + path: "{{ item }}" + state: directory + mode: 0750 + owner: "{{ atl_product_user }}" + group: "{{ atl_product_user }}" + with_items: + - "{{ atl_product_home_shared }}" + - "{{ atl_product_shared_plugins }}" diff --git a/roles/jira_startup/templates/jira.service.j2 b/roles/jira_startup/templates/jira.service.j2 index ba41ea5..62f513c 100644 --- a/roles/jira_startup/templates/jira.service.j2 +++ b/roles/jira_startup/templates/jira.service.j2 @@ -6,11 +6,11 @@ After=network-online.target User={{ atl_product_user }} Group={{ atl_product_user }} -# NOTE: Additional environment vars are set in {{ atl_product_installation_target }}/bin/setenv.sh +# NOTE: Additional environment vars are set in {{ atl_product_installation_current }}/bin/setenv.sh Environment="JIRA_HOME={{ atl_product_home }}" Environment="CATALINA_OPTS={{ atl_catalina_opts }} {{ atl_catalina_opts_extra }}" -ExecStart={{ atl_product_installation_target }}/bin/start-jira.sh -fg +ExecStart={{ atl_product_installation_current }}/bin/start-jira.sh -fg Restart=on-failure [Install] diff --git a/roles/product_common/defaults/main.yml b/roles/product_common/defaults/main.yml index daab5f3..d6c8b17 100644 --- a/roles/product_common/defaults/main.yml +++ b/roles/product_common/defaults/main.yml @@ -3,3 +3,8 @@ java_version: "1.8.0" java_major_version: "8" postgres_version: "9.6" git_version: "2.14.4" + +# Disable these when using the product installer, otherwise we end up +# fighting with it. +use_system_jdk: false +create_product_user: false diff --git a/roles/product_common/tasks/amazon.yml b/roles/product_common/tasks/amazon.yml index a37e1d4..afcbadc 100644 --- a/roles/product_common/tasks/amazon.yml +++ b/roles/product_common/tasks/amazon.yml @@ -1,17 +1,19 @@ --- -- name: Install Java and other base packages on Amazon Linux +- name: Install JDK if necessary on Amazon Linux yum: name: - java-{{ java_version }}-openjdk-devel + when: use_system_jdk + +- name: Install other base packages on Amazon Linux + yum: + name: - git-{{ git_version }} - tags: - - runtime_pkg + - dejavu-fonts-common # Amazon Linux 2 supplies extra packages via a special command. - name: Enable Postgresql from 'extras' command: amazon-linux-extras install -y "postgresql{{ postgres_version }}" args: creates: /usr/bin/psql - tags: - - runtime_pkg diff --git a/roles/product_common/tasks/main.yml b/roles/product_common/tasks/main.yml index 2a3e6ad..1a4b5e1 100644 --- a/roles/product_common/tasks/main.yml +++ b/roles/product_common/tasks/main.yml @@ -7,17 +7,4 @@ user: name: "{{ atl_product_user }}" comment: "Product runtime user" - -- name: Create installation directories - file: - path: "{{ item }}" - state: directory - mode: 0750 - owner: "{{ atl_product_user }}" - group: "{{ atl_product_user }}" - with_items: - - "{{ atl_product_home }}" - - "{{ atl_installer_temp }}" - - "{{ atl_product_home_shared }}" - - "{{ atl_product_shared_plugins }}" - - "{{ atl_product_installation_base }}" + when: create_product_user diff --git a/roles/product_common/tasks/ubuntu.yml b/roles/product_common/tasks/ubuntu.yml index 9cf5643..be6c16a 100644 --- a/roles/product_common/tasks/ubuntu.yml +++ b/roles/product_common/tasks/ubuntu.yml @@ -1,10 +1,18 @@ --- -- name: Install Java and other base packages on Ubuntu +- name: Install JDK if necessary on Ubuntu package: name: - openjdk-{{ java_major_version }}-jdk-headless + when: use_system_jdk + tags: + - runtime_pkg + +- name: Install other base packages on Ubuntu + package: + name: - postgresql-client + - fonts-dejavu-core - git tags: - runtime_pkg diff --git a/roles/tgz_download/tasks/fetch_product.yml b/roles/tgz_download/tasks/fetch_product.yml index a990dc5..20ba477 100644 --- a/roles/tgz_download/tasks/fetch_product.yml +++ b/roles/tgz_download/tasks/fetch_product.yml @@ -33,6 +33,6 @@ - name: Symlink the installed version to current file: src: "{{ atl_product_installation_base }}/{{ atl_product_version }}" - dest: "{{ atl_product_installation_target }}" + dest: "{{ atl_product_installation_current }}" state: link force: true