From 912bc7a2eba13874f34cee903045d348f7689bc3 Mon Sep 17 00:00:00 2001 From: Ben Partridge Date: Wed, 5 Jun 2019 16:06:40 +1000 Subject: [PATCH] Implement logic for setting targetServerType in multi-az rds deployments --- group_vars/aws_node_local.yml | 1 + .../molecule/multi_az_rds/Dockerfile.j2 | 14 ++++++++ .../molecule/multi_az_rds/molecule.yml | 32 +++++++++++++++++++ .../molecule/multi_az_rds/playbook.yml | 23 +++++++++++++ .../multi_az_rds/tests/test_multi_az_rds.py | 12 +++++++ 5 files changed, 82 insertions(+) create mode 100644 roles/confluence_config/molecule/multi_az_rds/Dockerfile.j2 create mode 100644 roles/confluence_config/molecule/multi_az_rds/molecule.yml create mode 100644 roles/confluence_config/molecule/multi_az_rds/playbook.yml create mode 100644 roles/confluence_config/molecule/multi_az_rds/tests/test_multi_az_rds.py diff --git a/group_vars/aws_node_local.yml b/group_vars/aws_node_local.yml index 5d0f330..8b180c4 100644 --- a/group_vars/aws_node_local.yml +++ b/group_vars/aws_node_local.yml @@ -73,6 +73,7 @@ atl_jdbc_ctype: "{{ lookup('env', 'ATL_JDBC_CTYPE') or 'en_US.UTF-8' }}" atl_jdbc_template: "{{ lookup('env', 'ATL_JDBC_TEMPLATE') or 'template1' }}" atl_jdbc_query_params_for_engine: aurora_postgres: "?targetServerType=master" + rds_postgres_multi_az: "?targetServerType=master" atl_jdbc_url: "jdbc:postgresql://{{ atl_db_host }}:{{ atl_db_port }}/{{ atl_jdbc_db_name }}{{ atl_jdbc_query_params_for_engine[atl_db_engine]| default('') }}" atl_jvm_heap: "{{ lookup('env', 'ATL_JVM_HEAP') or '2048m' }}" diff --git a/roles/confluence_config/molecule/multi_az_rds/Dockerfile.j2 b/roles/confluence_config/molecule/multi_az_rds/Dockerfile.j2 new file mode 100644 index 0000000..e6aa95d --- /dev/null +++ b/roles/confluence_config/molecule/multi_az_rds/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/confluence_config/molecule/multi_az_rds/molecule.yml b/roles/confluence_config/molecule/multi_az_rds/molecule.yml new file mode 100644 index 0000000..33c377c --- /dev/null +++ b/roles/confluence_config/molecule/multi_az_rds/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 + options: + x: ["701"] + inventory: + links: + group_vars: ../../../../group_vars/ +verifier: + name: testinfra + lint: + name: flake8 + enabled: false diff --git a/roles/confluence_config/molecule/multi_az_rds/playbook.yml b/roles/confluence_config/molecule/multi_az_rds/playbook.yml new file mode 100644 index 0000000..61b256f --- /dev/null +++ b/roles/confluence_config/molecule/multi_az_rds/playbook.yml @@ -0,0 +1,23 @@ +--- +- name: Converge + hosts: all + vars: + atl_product_family: "confluence" + atl_product_edition: "confluence" + atl_product_user: "confluence" + atl_product_version: "latest" + atl_db_engine: "rds_postgres_multi_az" + atl_db_host: "postgres-db.ap-southeast-2.rds.amazonaws.com" + atl_jdbc_db_name: "confluence" + atl_jdbc_user: 'confluence' + atl_jvm_heap: 'PLACEHOLDER' + atl_cluster_node_id: 'FAKEID' + atl_autologin_cookie_age: "COOKIEAGE" + atl_local_ipv4: "1.1.1.1" + + roles: + - role: linux_common + - role: product_common + - role: product_install + - role: confluence_common + - role: confluence_config diff --git a/roles/confluence_config/molecule/multi_az_rds/tests/test_multi_az_rds.py b/roles/confluence_config/molecule/multi_az_rds/tests/test_multi_az_rds.py new file mode 100644 index 0000000..0568593 --- /dev/null +++ b/roles/confluence_config/molecule/multi_az_rds/tests/test_multi_az_rds.py @@ -0,0 +1,12 @@ +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_confluence_config_file(host): + f = host.file('/var/atlassian/application-data/confluence/confluence.cfg.xml') + assert f.exists + assert f.contains('jdbc:postgresql://postgres-db.ap-southeast-2.rds.amazonaws.com:5432/confluence?targetServerType=master')