Skip to content

Development: Add support for Redis configuration #98

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
e19c8b9
Add new config options for Redis
bensofficial Aug 20, 2024
76425f3
Fix loop
bensofficial Aug 20, 2024
13dbf23
Add support for redis client name
Hialus Aug 21, 2024
d1e1a49
Merge branch 'main' into redis-support
bensofficial Aug 23, 2024
31ac537
Add support for different client names in multinode docker setups
bensofficial Oct 1, 2024
275eb26
Merge branch 'redis-support' of github.com:ls1intum/artemis-ansible-c…
bensofficial Oct 1, 2024
67efd2c
Add if conditions to redis config
bensofficial Oct 1, 2024
ae31ee8
Merge branch 'main' of github.com:ls1intum/artemis-ansible-collection…
bensofficial Jan 16, 2025
2af3bde
Merge branch 'feature/rename-broker-registry-firewall' of github.com:…
bensofficial Jan 16, 2025
873858a
Update roles/artemis/templates/artemis.env.j2
bensofficial Jan 16, 2025
1be63ac
Add Redis Role
bensofficial Jan 16, 2025
12817c8
Fix minor things while deploying
bensofficial Jan 23, 2025
de4cff7
Merge branch 'main' into redis-support
bensofficial Mar 2, 2025
57d3b94
Merge branch 'main' into redis-support
bensofficial Mar 3, 2025
25d5fc7
Remove if condition
bensofficial Mar 3, 2025
c07c763
Merge branch 'redis-support' of github.com:ls1intum/artemis-ansible-c…
bensofficial Mar 3, 2025
d9d7a74
Merge branch 'main' of github.com:ls1intum/artemis-ansible-collection…
bensofficial Apr 14, 2025
52868f1
Merge branch 'feat/update-breaking-config-changes-for-8.0' of github.…
bensofficial Apr 14, 2025
6f181c8
Merge branch 'main' into redis-support
bensofficial Apr 15, 2025
ada4ef8
Fix lint errors
bensofficial Apr 15, 2025
9e839a5
Fix lint errors
bensofficial Apr 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ roles:

collections:
- name: community.mysql
source: https://galaxy.ansible.com
- name: ansible.posix
source: https://galaxy.ansible.com
- name: community.docker
8 changes: 8 additions & 0 deletions roles/artemis/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,17 @@ artemis_eureka_urls: "{% if registry.url is defined and registry.url is not none
%}"
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 %}"

node_short_name: unnamed-artemis-node
node_display_name: Unnamed Artemis Node

#redis:
# host:
# port:
# username:
# password:

##############################################################################
# Iris Configuration
##############################################################################
Expand Down
21 changes: 6 additions & 15 deletions roles/artemis/tasks/docker_deploy_artemis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,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
Expand Down
11 changes: 11 additions & 0 deletions roles/artemis/templates/application-prod.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ 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 }}
client-name: {{ artemis_redis_client_name }}
{% endif %}

{% if is_multinode_install and hazelcast_address is defined %}
hazelcast:
interface: "{{ hazelcast_address }}"
Expand Down
8 changes: 8 additions & 0 deletions roles/artemis/templates/artemis.env.j2
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ SPRING_WEBSOCKET_BROKER_USERNAME='{{ broker.username }}'
SPRING_WEBSOCKET_BROKER_PASSWORD='{{ broker.password }}'
SPRING_WEBSOCKET_BROKER_ADDRESSES='{{ broker.url }}:61613'
{% 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 }}'
SPRING_DATA_REDIS_CLIENTNAME='{{ artemis_redis_client_name }}'
{% endif %}
{% if is_multinode_install and hazelcast_address is defined %}
SPRING_HAZELCAST_INTERFACE='{{ hazelcast_address }}'
{% endif %}
Expand Down
5 changes: 5 additions & 0 deletions roles/artemis/templates/docker.env.j2
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ 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 %}
REGISTRY_PASSWORD='{{ artemis_jhipster_registry_password }}'
Expand Down
3 changes: 3 additions & 0 deletions roles/artemis/templates/node.env.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@ 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 %}
ARTEMIS_CONTINUOUSINTEGRATION_BUILDAGENT_SHORTNAME='artemis-node-{{ docker_node_id }}'
ARTEMIS_CONTINUOUSINTEGRATION_BUILDAGENT_DISPLAYNAME='Artemis Node {{ docker_node_id }}'
19 changes: 19 additions & 0 deletions roles/redis/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Redis
=========

This role installes Redis in a docker container and configures it for the use with artemis.

Please install docker before continuing with this role.

Role Variables
--------------

Default variables can be found in the `defaults/main.yml` file.

You have to configure the follwoing varaibles in your ansible `group_vars`:

```
redis:
user: artemis # Also used by the artemis role
password: #FIXME # Also used by the artemis role
```
5 changes: 5 additions & 0 deletions roles/redis/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
redis:
user: artemis
password: #FIXME
working_directory: /opt/redis
version: 6.2.6-v18
5 changes: 5 additions & 0 deletions roles/redis/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- name: Restart redis
become: true
community.docker.docker_compose_v2:
project_src: "{{ redis.working_directory }}"
state: present
27 changes: 27 additions & 0 deletions roles/redis/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
- name: Check if redis.password is set
fail:
msg: "No redis password is configured!"
when:
- redis.password is undefined or redis.password is none

- name: Create working directory
become: true
file:
path: "{{ redis.working_directory }}"
state: directory
mode: '0775'
notify: Restart redis

- name: Copy configuration file
become: true
template:
src: "{{ item.src }}"
dest: "{{ redis.working_directory }}/{{ item.dest }}"
mode: '0600'
notify: Restart redis
with_items:
- src: redis.conf.j2
dest: "redis.conf"
- src: docker-compose.yml.j2
dest: "docker-compose.yml"
24 changes: 24 additions & 0 deletions roles/redis/templates/docker-compose.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{ ansible_managed | comment }}

services:
redis:
image: redis/redis-stack-server:latest
restart: always
ports:
- "6379:6379"
volumes:
- ./redis.conf:/usr/local/etc/redis/redis.conf
- ./redis-data:/data
command: [
"redis-server",
"/usr/local/etc/redis/redis.conf",
"--requirepass {{ redis.password }}",
"--user {{ redis.user }} on >{{ redis.password }} +@all &* ~*",
"--user default off nopass nocommands",
"--protected-mode no"
]
healthcheck:
test: ["CMD", "redis-cli", "-a", "{{ redis.password }}", "ping"]
interval: 10s
timeout: 5s
retries: 3
3 changes: 3 additions & 0 deletions roles/redis/templates/redis.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{ ansible_managed | comment }}

notify-keyspace-events lshKE