Skip to content

Commit

Permalink
Add multi-node support as well
Browse files Browse the repository at this point in the history
  • Loading branch information
Hialus committed Nov 10, 2023
1 parent 6510e27 commit 4f8bd1a
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 16 deletions.
3 changes: 2 additions & 1 deletion roles/artemis/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ artemis_server_port: 8080
install_artemis: true
upgrade_artemis: false
use_docker: false
artemis_node_count: 1

check_variables: true

Expand Down Expand Up @@ -178,7 +179,7 @@ artemis_external_password_reset_link_de: "https://campus.tum.de/tumonline/ee/ui/
# url:

# Define node local hazelcast_address - Uses wireguard net by default
hazelcast_address: "{% if is_multinode_install is defined and is_multinode_install|bool == true %}[{{ wireguard_interface_address }}]{% endif %}"
hazelcast_address: "{% if is_multinode_install is defined and is_multinode_install|bool == true and not use_docker%}[{{ wireguard_interface_address }}]{% endif %}"

artemis_eureka_urls: "{% if registry.url is defined and registry.url is not none %}http://admin:${jhipster.registry.password}@{{ registry.url }}:8761/eureka/{% endif %}"
artemis_eureka_instance_id: "{{ node_id }}"
Expand Down
15 changes: 15 additions & 0 deletions roles/artemis/tasks/docker_deploy_artemis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,21 @@
register: config
notify: restart docker artemis

- name: Copy node env files
loop: "{{ range(1, artemis_node_count + 1) }}"
loop_control:
loop_var: docker_node_id
when: is_multinode_install
become: true
template:
src: "templates/node.env.j2"
dest: "{{ artemis_working_directory }}/node{{ docker_node_id }}.env"
owner: "{{ artemis_user_name }}"
group: "{{ artemis_user_group }}"
mode: 0660
register: config
notify: restart docker artemis

- name: Create artemis ssh key directory
become: true
file:
Expand Down
20 changes: 5 additions & 15 deletions roles/artemis/templates/artemis-docker.sh.j2
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
#!/bin/bash

PROJECT_DIR="{{ artemis_working_directory }}/Artemis/docker"
{% if continuous_integration.localci is defined %}
{% if artemis_database_type == "mysql" %}
COMPOSE_FILE="test-server-mysql-localci.yml"
{% endif %}
{% if artemis_database_type == "postgresql" %}
COMPOSE_FILE="test-server-postgresql-localci.yml"
{% endif %}
{% else %}
{% if artemis_database_type == "mysql" %}
COMPOSE_FILE="test-server-mysql.yml"
{% endif %}
{% if artemis_database_type == "postgresql" %}
COMPOSE_FILE="test-server-postgresql.yml"
{% endif %}
{% endif %}
{% set default_compose_file = "test-server-" + artemis_database_type + ".yml" %}
{% set localci_compose_file = "test-server-" + artemis_database_type + "-localci.yml" %}
{% set multi_node_localci_compose_file = "test-server-multi-node-" + artemis_database_type + "-localci.yml" %}

COMPOSE_FILE="{% if continuous_integration.localci is defined and is_multinode_install is defined %}{{ multi_node_localci_compose_file }}{% elif continuous_integration.localci is defined %}{{ localci_compose_file }}{% else %}{{ default_compose_file }}{% endif %}"
ENV_FILE="{{ artemis_working_directory }}/docker.env"
{% if continuous_integration.localci is defined %}
export DOCKER_GROUP_ID=$(getent group docker | cut -d: -f3)
Expand Down
4 changes: 4 additions & 0 deletions roles/artemis/templates/artemis.env.j2
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,13 @@ INFO_SENTRY_DSN='https://[email protected]/2
EUREKA_CLIENT_ENABLED='true'
EUREKA_CLIENT_SERVICEURL_DEFAULTZONE='{{ artemis_eureka_urls }}'
EUREKA_INSTANCE_PREFERIPADDRESS='true'
{% if hazelcast_address is defined and hazelcast_address != "" %}
EUREKA_INSTANCE_IPADDRESS='{{ hazelcast_address }}'
{% endif %}
EUREKA_INSTANCE_APPNAME='Artemis'
{% if artemis_eureka_instance_id is defined and artemis_eureka_instance_id != "" %}
EUREKA_INSTANCE_INSTANCEID='Artemis:{{ artemis_eureka_instance_id }}'
{% endif %}
{% endif %}
LOGGING_FILE_NAME='{{ artemis_working_directory }}/artemis.log'
MANAGEMENT_METRICS_EXPORT_PROMETHEUS_ENABLED='true'
12 changes: 12 additions & 0 deletions roles/artemis/templates/docker.env.j2
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
ARTEMIS_DOCKER_TAG='{{ artemis_build_version }}'
ARTEMIS_SSH_KEY_PATH='{{ artemis_ssh_key_path }}'

ARTEMIS_ENV_FILE='{{ artemis_working_directory }}/artemis.env'
{% if is_multinode_install %}
{% for node_id in range(1, artemis_node_count + 1) %}
ARTEMIS_NODE_{{ node_id }}_ENV_FILE='{{ artemis_working_directory }}/node{{ node_id }}.env'
{% endfor %}
{% endif %}

ARTEMIS_VOLUME_MOUNT='{{ artemis_working_directory }}/data/artemis'
ARTEMIS_LEGAL_MOUNT='{{ artemis_working_directory }}/legal'
ARTEMIS_DATA_EXPORT_MOUNT='{{ artemis_working_directory }}/data-exports'

DATABASE_ENV_FILE='{{ artemis_working_directory }}/database.env'
DATABASE_VOLUME_MOUNT='{{ artemis_working_directory }}/data/database'

# Broker & Registry vars
REGISTRY_PASSWORD='{{ artemis_jhipster_registry_password }}'
BROKER_USER='{{ broker.username }}'
BROKER_PASSWORD='{{ broker.password }}'

# Nginx vars
NGINX_PROXY_SSL_CERTIFICATE_PATH='{{ proxy_ssl_certificate_path }}'
NGINX_PROXY_SSL_CERTIFICATE_KEY_PATH='{{ proxy_ssl_certificate_key_path }}'
4 changes: 4 additions & 0 deletions roles/artemis/templates/node.env.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SPRING_PROFILES_ACTIVE='{{ artemis_spring_profiles }}{% if docker_node_id == 1 %},scheduling{% endif %}'
EUREKA_INSTANCE_INSTANCEID='Artemis:{{ docker_node_id }}'
EUREKA_INSTANCE_HOSTNAME='artemis-app-node-{{ docker_node_id }}'
SPRING_HAZELCAST_INTERFACE='artemis-app-node-{{ docker_node_id }}'

0 comments on commit 4f8bd1a

Please sign in to comment.