diff --git a/config/confluence.cfg.xml.j2 b/config/confluence.cfg.xml.j2
index b51e4f9..189fa1d 100644
--- a/config/confluence.cfg.xml.j2
+++ b/config/confluence.cfg.xml.j2
@@ -36,17 +36,23 @@
{{ atl_db_validationquery | default('select 1') }}
{% endif %}
- {# {{ atl_product_home_shared | default('') }} #}
- {# true #}
- {# {{ atl_product_home_shared | default('') }} #}
- {# {{ atl_hazelcast_network_aws_iam_role | default('') }} #}
- {# {{ atl_hazelcast_network_aws_iam_region | default('') }} #}
- {# {{ atl_hazelcast_network_aws_host_header | default('') }} #}
- {# {{ atl_hazelcast_network_aws_tag_key | default('') }} #}
- {# {{ atl_hazelcast_network_aws_tag_value | default('') }} #}
- {# aws #}
- {# {{ atl_aws_stack_name | default('') }} #}
- {# 1 #}
+ {% if atl_cluster_type is defined %}
+ true
+ {{ atl_cluster_type }}
+ {{ atl_product_home_shared }}
+ {{ atl_product_home_shared }}
+
+ {% if atl_cluster_type == 'aws' %}
+ {{ atl_hazelcast_network_aws_iam_role }}
+ {{ atl_hazelcast_network_aws_iam_region }}
+ {{ atl_hazelcast_network_aws_host_header }}
+ {{ atl_hazelcast_network_aws_tag_key }}
+ {{ atl_hazelcast_network_aws_tag_value }}
+ {{ atl_cluster_name }}
+ {{ atl_cluster_ttl }}
+ {% endif %}
+
+ {% endif %}
diff --git a/entrypoint.py b/entrypoint.py
index 6ad62cd..8254462 100755
--- a/entrypoint.py
+++ b/entrypoint.py
@@ -25,18 +25,16 @@ def gen_cfg(tmpl, target, env, user='root', group='root', mode=0o644):
######################################################################
# Setup inputs and outputs
-# Extract some common parameters
-confluence_home = os.environ["CONFLUENCE_HOME"]
-confluence_install_dir = os.environ["CONFLUENCE_INSTALL_DIR"]
-user = os.environ["RUN_USER"]
-group = os.environ["RUN_GROUP"]
-
-# Import all ATL_* environment variables. We lower-case these for
-# compatability with Ansible template convention. We handle default
-# and legacy mappings below.
+# Import all ATL_* and Dockerfile environment variables. We
+# lower-case these for compatability with Ansible template
+# convention. We handle default and legacy mappings below.
env = {k.lower(): v
for k, v in os.environ.items()
- if k.startswith('ATL_')}
+ if k.startswith(('ATL_', 'CONFLUENCE_', 'RUN_'))}
+
+# For compatability with the Ansible templates.
+env['atl_product_home'] = env['confluence_home']
+env['atl_product_home_shared'] = env.get('confluence_shared_home')
# Setup Jinja2 for templating
jenv = j2.Environment(
@@ -74,7 +72,7 @@ for key, defval in defaults.items():
if (key not in env) and defval:
env[key] = defval
-gen_cfg('server.xml.j2', confluence_install_dir+'/conf/server.xml', env)
+gen_cfg('server.xml.j2', env['confluence_install_dir']+'/conf/server.xml', env)
######################################################################
@@ -83,35 +81,33 @@ gen_cfg('server.xml.j2', confluence_install_dir+'/conf/server.xml', env)
# The default is two weeks, in seconds, same as the seraph default.
env['atl_autologin_cookie_age'] = env.get('atl_autologin_cookie_age', "1209600")
-gen_cfg('seraph-config.xml.j2', confluence_install_dir+'/confluence/WEB-INF/classes/seraph-config.xml', env)
+gen_cfg('seraph-config.xml.j2', env['confluence_install_dir']+'/confluence/WEB-INF/classes/seraph-config.xml', env)
######################################################################
# Configure confluence-init.properties
-# For compatability with the Ansible templates.
-env['atl_product_home'] = confluence_home
-gen_cfg('confluence-init.properties.j2', confluence_install_dir+'/confluence/WEB-INF/classes/confluence-init.properties', env)
+gen_cfg('confluence-init.properties.j2', env['confluence_install_dir']+'/confluence/WEB-INF/classes/confluence-init.properties', env)
######################################################################
# Configure confluence.cfg.xml
-gen_cfg('confluence.cfg.xml.j2', confluence_home+'/confluence.cfg.xml', env,
- user=user, group=group, mode=0o640)
+gen_cfg('confluence.cfg.xml.j2', env['confluence_home']+'/confluence.cfg.xml', env,
+ user=env['run_user'], group=env['run_group'], mode=0o640)
######################################################################
# Start Confluence as the correct user
-start_cmd = "{}/bin/start-confluence.sh".format(confluence_install_dir)
+start_cmd = "{}/bin/start-confluence.sh".format(env['confluence_install_dir'])
if os.getuid() == 0:
- logging.info("User is currently root. Will change directory ownership to {}:{}, then downgrade permission to {}".format(user, group, user))
- set_perms(confluence_home, user, group, 0o700)
+ logging.info("User is currently root. Will change directory ownership to {} then downgrade permissions".format(env['run_user']))
+ set_perms(env['confluence_home'], env['run_user'], env['run_group'], 0o700)
cmd = '/bin/su'
start_cmd = ' '.join([start_cmd] + sys.argv[1:])
- args = [cmd, user, '-c', start_cmd]
+ args = [cmd, env['run_user'], '-c', start_cmd]
else:
cmd = start_cmd
args = [start_cmd] + sys.argv[1:]
diff --git a/tests/test_image.py b/tests/test_image.py
index 4ecf84c..de4860c 100644
--- a/tests/test_image.py
+++ b/tests/test_image.py
@@ -182,6 +182,7 @@ def test_confluence_xml_default(docker_cli, image):
xml = etree.fromstring(container.file('/var/atlassian/application-data/confluence/confluence.cfg.xml').content)
assert xml.xpath('/confluence-configuration/buildNumber')[0].text == "0"
assert xml.xpath('/confluence-configuration/properties/property[@name="hibernate.connection.url"]') == []
+ assert xml.xpath('/confluence-configuration/properties/property[@name="confluence.cluster.home"]') == []
def test_confluence_xml_postgres(docker_cli, image):
environment = {
@@ -239,3 +240,30 @@ def test_confluence_xml_postgres_all_set(docker_cli, image):
assert xml.xpath('//property[@name="hibernate.c3p0.validate"]')[0].text == "xfalse"
assert xml.xpath('//property[@name="hibernate.c3p0.acquire_increment"]')[0].text == "x1"
assert xml.xpath('//property[@name="hibernate.c3p0.preferredTestQuery"]')[0].text == "xselect 1"
+
+
+def test_confluence_xml_cluster_aws(docker_cli, image):
+ environment = {
+ 'ATL_CLUSTER_TYPE': 'aws',
+ 'ATL_HAZELCAST_NETWORK_AWS_IAM_ROLE': 'atl_hazelcast_network_aws_iam_role',
+ 'ATL_HAZELCAST_NETWORK_AWS_IAM_REGION': 'atl_hazelcast_network_aws_iam_region',
+ 'ATL_HAZELCAST_NETWORK_AWS_HOST_HEADER': 'atl_hazelcast_network_aws_host_header',
+ 'ATL_HAZELCAST_NETWORK_AWS_TAG_KEY': 'atl_hazelcast_network_aws_tag_key',
+ 'ATL_HAZELCAST_NETWORK_AWS_TAG_VALUE': 'atl_hazelcast_network_aws_tag_value',
+ 'ATL_CLUSTER_NAME': 'atl_cluster_name',
+ 'ATL_CLUSTER_TTL': 'atl_cluster_ttl'
+ }
+ container = run_image(docker_cli, image, environment=environment)
+ wait_for_file(container, "/var/atlassian/application-data/confluence/confluence.cfg.xml")
+ xml = etree.fromstring(container.file('/var/atlassian/application-data/confluence/confluence.cfg.xml').content)
+
+ assert xml.xpath('//property[@name="confluence.cluster"]')[0].text == "true"
+ assert xml.xpath('//property[@name="confluence.cluster.join.type"]')[0].text == "aws"
+
+ assert xml.xpath('//property[@name="confluence.cluster.aws.iam.role"]')[0].text == "atl_hazelcast_network_aws_iam_role"
+ assert xml.xpath('//property[@name="confluence.cluster.aws.region"]')[0].text == "atl_hazelcast_network_aws_iam_region"
+ assert xml.xpath('//property[@name="confluence.cluster.aws.host.header"]')[0].text == "atl_hazelcast_network_aws_host_header"
+ assert xml.xpath('//property[@name="confluence.cluster.aws.tag.key"]')[0].text == "atl_hazelcast_network_aws_tag_key"
+ assert xml.xpath('//property[@name="confluence.cluster.aws.tag.value"]')[0].text == "atl_hazelcast_network_aws_tag_value"
+ assert xml.xpath('//property[@name="confluence.cluster.name"]')[0].text == "atl_cluster_name"
+ assert xml.xpath('//property[@name="confluence.cluster.ttl"]')[0].text == "atl_cluster_ttl"