From e19c8b97085b398288b57a731c3e7d6bbb5a1c03 Mon Sep 17 00:00:00 2001 From: Benjamin Schmitz Date: Tue, 20 Aug 2024 16:35:28 +0200 Subject: [PATCH 1/5] Add new config options for Redis --- roles/artemis/defaults/main.yml | 6 ++++++ roles/artemis/tasks/docker_deploy_artemis.yml | 21 ++++++------------- .../artemis/templates/application-prod.yml.j2 | 10 +++++++++ roles/artemis/templates/artemis.env.j2 | 9 ++++++++ roles/artemis/templates/docker.env.j2 | 3 +++ 5 files changed, 34 insertions(+), 15 deletions(-) diff --git a/roles/artemis/defaults/main.yml b/roles/artemis/defaults/main.yml index 9b4b282..76e9ecd 100644 --- a/roles/artemis/defaults/main.yml +++ b/roles/artemis/defaults/main.yml @@ -226,6 +226,12 @@ hazelcast_address: "{% if is_multinode_install is defined and is_multinode_insta 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 }}" +#redis: +# host: +# port: +# username: +# password: + ############################################################################## # Iris Configuration ############################################################################## diff --git a/roles/artemis/tasks/docker_deploy_artemis.yml b/roles/artemis/tasks/docker_deploy_artemis.yml index 80adb82..9c03fea 100644 --- a/roles/artemis/tasks/docker_deploy_artemis.yml +++ b/roles/artemis/tasks/docker_deploy_artemis.yml @@ -8,23 +8,14 @@ - name: Create artemis data directory become: true file: - path: "{{ artemis_working_directory }}/data" - state: directory - mode: '0770' - -- name: Create artemis database directory - become: true - file: - path: "{{ artemis_working_directory }}/data/database" - state: directory - mode: '0770' - -- name: Create artemis data/artemis directory - become: true - file: - path: "{{ artemis_working_directory }}/data/artemis" + path: "{{ artemis_working_directory }}/{{ item }}" state: directory mode: '0770' + loop: + - "/data" + - "/data/database" + - "/data/artemis" + - "/data/redis" - name: Set permissions for artemis directory become: true diff --git a/roles/artemis/templates/application-prod.yml.j2 b/roles/artemis/templates/application-prod.yml.j2 index 939b90c..786e14d 100644 --- a/roles/artemis/templates/application-prod.yml.j2 +++ b/roles/artemis/templates/application-prod.yml.j2 @@ -32,6 +32,16 @@ spring: addresses: "{{ broker.url }}:61613" {% endif %} {% endif %} + +{% if redis is defined and redis is not none %} + data: + redis: + host: {{ redis.host }} + port: {{ redis.port}} + username: {{ redis.username}} + password: {{ redis.password }} +{% endif %} + {% if is_multinode_install and hazelcast_address is defined %} hazelcast: interface: "{{ hazelcast_address }}" diff --git a/roles/artemis/templates/artemis.env.j2 b/roles/artemis/templates/artemis.env.j2 index a91ed9a..9e3d53b 100644 --- a/roles/artemis/templates/artemis.env.j2 +++ b/roles/artemis/templates/artemis.env.j2 @@ -1,6 +1,7 @@ SPRING_PROFILES_ACTIVE: '{{ artemis_spring_profiles }}' _JAVA_OPTIONS: '-Xmx3g -Xms1g' +{% if artemis_computed_is_core_node %} SPRING_DATASOURCE_TYPE='com.zaxxer.hikari.HikariDataSource' SPRING_DATASOURCE_URL='jdbc:{{ artemis_database_type }}://{{ artemis_database_host }}:{{ artemis_database_port }}/{{ artemis_database_dbname }}?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=utf8&allowPublicKeyRetrieval=true&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC' SPRING_DATASOURCE_USERNAME='{{ artemis_database_username }}' @@ -22,6 +23,14 @@ SPRING_WEBSOCKET_BROKER_USERNAME='{{ broker.username }}' SPRING_WEBSOCKET_BROKER_PASSWORD='{{ broker.password }}' SPRING_WEBSOCKET_BROKER_ADDRESSES='{{ broker.url }}:61613' {% endif %} +{% endif %} + +{% if redis is defined and redis is not none %} +SPRING_DATA_REDIS_HOST='{{ redis.host }}' +SPRING_DATA_REDIS_PORT='{{ redis.port}}' +SPRING_DATA_REDIS_USERNAME='{{ redis.username}}' +SPRING_DATA_REDIS_PASSWORD='{{ redis.password }}' +{% endif %} {% if is_multinode_install and hazelcast_address is defined %} SPRING_HAZELCAST_INTERFACE='{{ hazelcast_address }}' {% endif %} diff --git a/roles/artemis/templates/docker.env.j2 b/roles/artemis/templates/docker.env.j2 index 793e5b1..256555b 100644 --- a/roles/artemis/templates/docker.env.j2 +++ b/roles/artemis/templates/docker.env.j2 @@ -15,6 +15,9 @@ 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' +REDIS_DATA_VOLUME='{{ artemis_working_directory }}/data/redis' +REDIS_PASSWORD='{{ redis.password }}' + # Broker & Registry vars {% if is_multinode_install %} REGISTRY_PASSWORD='{{ artemis_jhipster_registry_password }}' From 76425f353b54e0c3355aaa206599134a9349e06f Mon Sep 17 00:00:00 2001 From: Benjamin Schmitz Date: Tue, 20 Aug 2024 16:39:00 +0200 Subject: [PATCH 2/5] Fix loop --- roles/artemis/tasks/docker_deploy_artemis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/roles/artemis/tasks/docker_deploy_artemis.yml b/roles/artemis/tasks/docker_deploy_artemis.yml index 9c03fea..7bc56d7 100644 --- a/roles/artemis/tasks/docker_deploy_artemis.yml +++ b/roles/artemis/tasks/docker_deploy_artemis.yml @@ -12,10 +12,10 @@ state: directory mode: '0770' loop: - - "/data" - - "/data/database" - - "/data/artemis" - - "/data/redis" + - "data" + - "data/database" + - "data/artemis" + - "data/redis" - name: Set permissions for artemis directory become: true From 13dbf23eb4666e265a1fccc3dcf74271d91170ab Mon Sep 17 00:00:00 2001 From: Timor Morrien Date: Wed, 21 Aug 2024 12:42:08 +0200 Subject: [PATCH 3/5] Add support for redis client name --- roles/artemis/defaults/main.yml | 2 ++ roles/artemis/templates/application-prod.yml.j2 | 1 + roles/artemis/templates/artemis.env.j2 | 1 + 3 files changed, 4 insertions(+) diff --git a/roles/artemis/defaults/main.yml b/roles/artemis/defaults/main.yml index 76e9ecd..e8148ef 100644 --- a/roles/artemis/defaults/main.yml +++ b/roles/artemis/defaults/main.yml @@ -226,6 +226,8 @@ hazelcast_address: "{% if is_multinode_install is defined and is_multinode_insta 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 }}" +artemis_redis_client_name: "{% if artemis_redis_client_name is defined %}{{ artemis_redis_client_name }}{% else %}{{ artemis_eureka_instance_id }}{% endif %}" + #redis: # host: # port: diff --git a/roles/artemis/templates/application-prod.yml.j2 b/roles/artemis/templates/application-prod.yml.j2 index 786e14d..e969762 100644 --- a/roles/artemis/templates/application-prod.yml.j2 +++ b/roles/artemis/templates/application-prod.yml.j2 @@ -40,6 +40,7 @@ spring: port: {{ redis.port}} username: {{ redis.username}} password: {{ redis.password }} + client-name: {{ artemis_redis_client_name }} {% endif %} {% if is_multinode_install and hazelcast_address is defined %} diff --git a/roles/artemis/templates/artemis.env.j2 b/roles/artemis/templates/artemis.env.j2 index 9e3d53b..8ed26a2 100644 --- a/roles/artemis/templates/artemis.env.j2 +++ b/roles/artemis/templates/artemis.env.j2 @@ -30,6 +30,7 @@ SPRING_DATA_REDIS_HOST='{{ redis.host }}' SPRING_DATA_REDIS_PORT='{{ redis.port}}' SPRING_DATA_REDIS_USERNAME='{{ redis.username}}' SPRING_DATA_REDIS_PASSWORD='{{ redis.password }}' +SPRING_DATA_REDIS_CLIENTNAME='{{ artemis_eureka_instance_id }}' {% endif %} {% if is_multinode_install and hazelcast_address is defined %} SPRING_HAZELCAST_INTERFACE='{{ hazelcast_address }}' From 31ac53761a6af8d2793eac6fdf22549b9da21f51 Mon Sep 17 00:00:00 2001 From: Benjamin Schmitz Date: Tue, 1 Oct 2024 11:57:22 +0200 Subject: [PATCH 4/5] Add support for different client names in multinode docker setups --- roles/artemis/templates/node.env.j2 | 1 + 1 file changed, 1 insertion(+) diff --git a/roles/artemis/templates/node.env.j2 b/roles/artemis/templates/node.env.j2 index 6f752a7..6b485db 100644 --- a/roles/artemis/templates/node.env.j2 +++ b/roles/artemis/templates/node.env.j2 @@ -2,3 +2,4 @@ SPRING_PROFILES_ACTIVE='{{ artemis_spring_profiles }}{% if docker_node_id == 1 % 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 }}' +SPRING_DATA_REDIS_CLIENTNAME='{{ artemis_redis_client_name }}' From 67efd2cbd992f0d60b87fa6b839eebd8d091850b Mon Sep 17 00:00:00 2001 From: Benjamin Schmitz Date: Tue, 1 Oct 2024 12:08:21 +0200 Subject: [PATCH 5/5] Add if conditions to redis config --- roles/artemis/templates/docker.env.j2 | 2 ++ roles/artemis/templates/node.env.j2 | 2 ++ 2 files changed, 4 insertions(+) diff --git a/roles/artemis/templates/docker.env.j2 b/roles/artemis/templates/docker.env.j2 index 256555b..1df5381 100644 --- a/roles/artemis/templates/docker.env.j2 +++ b/roles/artemis/templates/docker.env.j2 @@ -15,8 +15,10 @@ 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' +{% if redis is defined and redis is not none %} REDIS_DATA_VOLUME='{{ artemis_working_directory }}/data/redis' REDIS_PASSWORD='{{ redis.password }}' +{% endif %} # Broker & Registry vars {% if is_multinode_install %} diff --git a/roles/artemis/templates/node.env.j2 b/roles/artemis/templates/node.env.j2 index 6b485db..b201fae 100644 --- a/roles/artemis/templates/node.env.j2 +++ b/roles/artemis/templates/node.env.j2 @@ -2,4 +2,6 @@ SPRING_PROFILES_ACTIVE='{{ artemis_spring_profiles }}{% if docker_node_id == 1 % 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 }}' +{% if redis is defined and redis is not none %} SPRING_DATA_REDIS_CLIENTNAME='{{ artemis_redis_client_name }}' +{% endif %}