From 0d3ef898adfe7673ccb66084d47ed2297ad441ba Mon Sep 17 00:00:00 2001 From: Steve Smith Date: Fri, 31 Jan 2020 11:47:46 +1100 Subject: [PATCH 1/2] DCD-933: Add functionality to copy jira-config.properties if present. --- bitbucket-pipelines.yml | 10 ++- .../molecule/default/tests/test_default.py | 5 ++ .../molecule/jira_config_props/Dockerfile.j2 | 14 ++++ .../molecule/jira_config_props/molecule.yml | 36 ++++++++ .../molecule/jira_config_props/playbook.yml | 44 ++++++++++ .../jira_config_props/tests/test_default.py | 82 +++++++++++++++++++ roles/jira_config/tasks/main.yml | 12 +++ 7 files changed, 202 insertions(+), 1 deletion(-) create mode 100644 roles/jira_config/molecule/jira_config_props/Dockerfile.j2 create mode 100644 roles/jira_config/molecule/jira_config_props/molecule.yml create mode 100644 roles/jira_config/molecule/jira_config_props/playbook.yml create mode 100644 roles/jira_config/molecule/jira_config_props/tests/test_default.py diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml index 10e3829..2c613db 100644 --- a/bitbucket-pipelines.yml +++ b/bitbucket-pipelines.yml @@ -18,7 +18,7 @@ pipelines: - step: name: Pre Parallelization stage script: - - echo "Running tests in 34 batches" + - echo "Running tests in 35 batches" - step: name: Check if number of batches match actual number of scenarios script: @@ -303,4 +303,12 @@ pipelines: - apt-get update && ./bin/install-ansible --dev - ./bin/run-tests-in-batches --batch 34 + - step: + name: Molecule Test Batch - 35 + services: + - docker + script: + - apt-get update && ./bin/install-ansible --dev + - ./bin/run-tests-in-batches --batch 35 + diff --git a/roles/jira_config/molecule/default/tests/test_default.py b/roles/jira_config/molecule/default/tests/test_default.py index df921e3..5a7b961 100644 --- a/roles/jira_config/molecule/default/tests/test_default.py +++ b/roles/jira_config/molecule/default/tests/test_default.py @@ -48,6 +48,11 @@ def test_cluster_file(host): assert f.contains('jira.shared.home = /media/atl/jira/shared') +def test_jira_config_prop(host): + f = host.file('/var/atlassian/application-data/jira/jira-config.properties') + assert not f.exists + + def test_server_file(host): f = host.file('/opt/atlassian/jira-software/current/conf/server.xml') assert f.exists diff --git a/roles/jira_config/molecule/jira_config_props/Dockerfile.j2 b/roles/jira_config/molecule/jira_config_props/Dockerfile.j2 new file mode 100644 index 0000000..e6aa95d --- /dev/null +++ b/roles/jira_config/molecule/jira_config_props/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/jira_config/molecule/jira_config_props/molecule.yml b/roles/jira_config/molecule/jira_config_props/molecule.yml new file mode 100644 index 0000000..7f082f6 --- /dev/null +++ b/roles/jira_config/molecule/jira_config_props/molecule.yml @@ -0,0 +1,36 @@ +--- +dependency: + name: galaxy +driver: + name: docker +lint: + name: yamllint +platforms: + - name: amazon_linux2 + image: amazonlinux:2 + groups: + - aws_node_local + ulimits: + - nofile:262144:262144 + - name: ubuntu_lts + image: ubuntu:bionic + groups: + - aws_node_local + ulimits: + - nofile:262144:262144 +provisioner: + name: ansible + options: + skip-tags: runtime_pkg + lint: + name: ansible-lint + options: + x: ["701"] + inventory: + links: + group_vars: ../../../../group_vars/ +verifier: + name: testinfra + lint: + name: flake8 + enabled: false diff --git a/roles/jira_config/molecule/jira_config_props/playbook.yml b/roles/jira_config/molecule/jira_config_props/playbook.yml new file mode 100644 index 0000000..9ef9fa9 --- /dev/null +++ b/roles/jira_config/molecule/jira_config_props/playbook.yml @@ -0,0 +1,44 @@ +--- +- name: Converge + hosts: all + vars: + atl_product_family: "jira" + atl_product_edition: "jira-software" + atl_product_user: "jira" + atl_product_version: "7.13.2" + + # dbconfig.xml variables + atl_jdbc_user: 'atljira' + atl_jdbc_password: 'molecule_password' + atl_jvm_heap: 'PLACEHOLDER' + atl_jvm_opts: 'PLACEHOLDER' + atl_cluster_node_id: 'FAKEID' + atl_db_poolminsize: 1111 + atl_db_poolmaxsize: 1111 + atl_db_minidle: 1111 + atl_db_maxidle: 1111 + atl_db_maxwaitmillis: 1111 + atl_db_minevictableidletimemillis: 1111 + atl_db_timebetweenevictionrunsmillis: 1111 + atl_db_removeabandoned: 'false' + atl_db_removeabandonedtimeout: 1111 + atl_db_testwhileidle: 'false' + atl_db_testonborrow: 'true' + atl_db_engine: 'rds_postgres' + + pre_tasks: + - name: Create shared home + file: + path: '/media/atl/jira/shared/' + state: directory + - name: Create jira-config.properties to check copy + copy: + dest: '/media/atl/jira/shared/jira-config.properties' + content: "jira.projectkey.warning = testwarning" + force: false # For idempotency check + + roles: + - role: linux_common + - role: product_common + - role: product_install + - role: jira_config diff --git a/roles/jira_config/molecule/jira_config_props/tests/test_default.py b/roles/jira_config/molecule/jira_config_props/tests/test_default.py new file mode 100644 index 0000000..4287ee6 --- /dev/null +++ b/roles/jira_config/molecule/jira_config_props/tests/test_default.py @@ -0,0 +1,82 @@ +import os + +import testinfra.utils.ansible_runner + +testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') + + +def test_dbconfig_file(host): + f = host.file('/var/atlassian/application-data/jira/dbconfig.xml') + assert f.exists + assert f.user == 'jira' + assert f.contains("postgres72") + assert f.contains("org.postgresql.Driver") + assert f.contains("atljira") + assert f.contains("molecule_password") + + assert f.contains("1111") + assert f.contains("1111") + assert f.contains("1111") + assert f.contains("1111") + + assert f.contains("1111") + assert f.contains("1111") + assert f.contains("false") + assert f.contains("1111") + assert f.contains("1111") + assert f.contains("false") + assert f.contains("1111") + assert f.contains("false") + assert f.contains("true") + + +def test_setenv_file(host): + f = host.file('/opt/atlassian/jira-software/current/bin/setenv.sh') + assert f.exists + assert f.contains('^JVM_MINIMUM_MEMORY="PLACEHOLDER"') + assert f.contains('^JVM_MAXIMUM_MEMORY="PLACEHOLDER"') + assert f.contains('^JIRA_HOME="/var/atlassian/application-data/jira"') + assert f.contains('^export CATALINA_OPTS="') + assert f.contains('^JVM_SUPPORT_RECOMMENDED_ARGS="PLACEHOLDER"') + + +def test_cluster_file(host): + f = host.file('/var/atlassian/application-data/jira/cluster.properties') + assert f.exists + assert f.contains('jira.node.id = FAKEID') + assert f.contains('jira.shared.home = /media/atl/jira/shared') + + +def test_jira_config_prop(host): + f = host.file('/var/atlassian/application-data/jira/jira-config.properties') + assert f.exists + assert f.contains('jira.projectkey.warning = testwarning') + + +def test_server_file(host): + f = host.file('/opt/atlassian/jira-software/current/conf/server.xml') + assert f.exists + assert f.contains('Connector port="8080"') + assert f.contains('Server port="8005"') + assert f.contains(' Date: Fri, 31 Jan 2020 12:52:24 +1100 Subject: [PATCH 2/2] DCD-933: Document new jira-config.properties behaviour. --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index e33ea18..2738c58 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,14 @@ to find them: repo:dc-deployments-automation repo:dc-deployments-automation path:*/defaults/main.yml atl +### Custom files + +* `jira-config.properties`: If this file exists in the shared home (default: + `/media/atl/jira/shared/`) then it will be copied to the Jira local home + directory (default: `/var/atlassian/application-data/jira/`). Note that this + only happens on node creation; if you create or update the shared file it will + need to be copied manually. + # Development and testing See [Development](DEVELOPMENT.md) for details on setting up a development