mirror of
https://bitbucket.org/atlassian-docker/docker-atlassian-confluence-server.git
synced 2024-08-30 18:22:16 +00:00
DCD-558: Start of cluster configuration, and refactor the env dict is the source of truth for parameters.
This commit is contained in:
parent
3f5e23663c
commit
e1fc7fe9c6
@ -36,17 +36,23 @@
|
||||
<property name="hibernate.c3p0.preferredTestQuery">{{ atl_db_validationquery | default('select 1') }}</property>
|
||||
{% endif %}
|
||||
|
||||
{# <property name="shared-home">{{ atl_product_home_shared | default('') }}</property> #}
|
||||
{# <property name="confluence.cluster">true</property> #}
|
||||
{# <property name="confluence.cluster.home">{{ atl_product_home_shared | default('') }}</property> #}
|
||||
{# <property name="confluence.cluster.aws.iam.role">{{ atl_hazelcast_network_aws_iam_role | default('') }}</property> #}
|
||||
{# <property name="confluence.cluster.aws.region">{{ atl_hazelcast_network_aws_iam_region | default('') }}</property> #}
|
||||
{# <property name="confluence.cluster.aws.host.header">{{ atl_hazelcast_network_aws_host_header | default('') }}</property> #}
|
||||
{# <property name="confluence.cluster.aws.tag.key">{{ atl_hazelcast_network_aws_tag_key | default('') }}</property> #}
|
||||
{# <property name="confluence.cluster.aws.tag.value">{{ atl_hazelcast_network_aws_tag_value | default('') }}</property> #}
|
||||
{# <property name="confluence.cluster.join.type">aws</property> #}
|
||||
{# <property name="confluence.cluster.name">{{ atl_aws_stack_name | default('') }}</property> #}
|
||||
{# <property name="confluence.cluster.ttl">1</property> #}
|
||||
{% if atl_cluster_type is defined %}
|
||||
<property name="confluence.cluster">true</property>
|
||||
<property name="confluence.cluster.join.type">{{ atl_cluster_type }}</property>
|
||||
<property name="confluence.cluster.home">{{ atl_product_home_shared }}</property>
|
||||
<property name="shared-home">{{ atl_product_home_shared }}</property>
|
||||
|
||||
{% if atl_cluster_type == 'aws' %}
|
||||
<property name="confluence.cluster.aws.iam.role">{{ atl_hazelcast_network_aws_iam_role }}</property>
|
||||
<property name="confluence.cluster.aws.region">{{ atl_hazelcast_network_aws_iam_region }}</property>
|
||||
<property name="confluence.cluster.aws.host.header">{{ atl_hazelcast_network_aws_host_header }}</property>
|
||||
<property name="confluence.cluster.aws.tag.key">{{ atl_hazelcast_network_aws_tag_key }}</property>
|
||||
<property name="confluence.cluster.aws.tag.value">{{ atl_hazelcast_network_aws_tag_value }}</property>
|
||||
<property name="confluence.cluster.name">{{ atl_cluster_name }}</property>
|
||||
<property name="confluence.cluster.ttl">{{ atl_cluster_ttl }}</property>
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
|
||||
</properties>
|
||||
</confluence-configuration>
|
||||
|
@ -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:]
|
||||
|
@ -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"
|
||||
|
Loading…
x
Reference in New Issue
Block a user