parent
519b32543c
commit
990a6369e1
@ -1,25 +0,0 @@
|
||||
---
|
||||
# Project source code URL: https://github.com/redis/redis
|
||||
|
||||
matrix_redis_enabled: true
|
||||
|
||||
matrix_redis_connection_password: ""
|
||||
|
||||
matrix_redis_base_path: "{{ matrix_base_data_path }}/redis"
|
||||
matrix_redis_data_path: "{{ matrix_redis_base_path }}/data"
|
||||
|
||||
matrix_redis_version: 7.0.7-alpine
|
||||
matrix_redis_docker_image_v6: "{{ matrix_container_global_registry_prefix }}redis:{{ matrix_redis_version }}"
|
||||
matrix_redis_docker_image_latest: "{{ matrix_redis_docker_image_v6 }}"
|
||||
matrix_redis_docker_image_to_use: '{{ matrix_redis_docker_image_latest }}'
|
||||
|
||||
matrix_redis_docker_image_force_pull: "{{ matrix_redis_docker_image_to_use.endswith(':latest') }}"
|
||||
|
||||
# A list of extra arguments to pass to the container
|
||||
matrix_redis_container_extra_arguments: []
|
||||
|
||||
# Controls whether the matrix-redis container exposes a port (tcp/6379 in the container)
|
||||
# that can be used to access redis from outside the container
|
||||
#
|
||||
# Takes an "<ip>:<port>" or "<port>" value (e.g. "127.0.0.1:6379"), or empty string to not expose.
|
||||
matrix_redis_container_redis_bind_port: ""
|
@ -1,17 +0,0 @@
|
||||
---
|
||||
|
||||
- block:
|
||||
- when: matrix_redis_enabled | bool
|
||||
ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-redis
|
||||
- install-all
|
||||
- install-redis
|
||||
|
||||
- block:
|
||||
- when: not matrix_redis_enabled | bool
|
||||
ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-redis
|
@ -1,49 +0,0 @@
|
||||
---
|
||||
|
||||
- name: Ensure redis Docker image is pulled
|
||||
community.docker.docker_image:
|
||||
name: "{{ matrix_redis_docker_image_to_use }}"
|
||||
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
|
||||
force_source: "{{ matrix_redis_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
|
||||
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_redis_docker_image_force_pull }}"
|
||||
register: result
|
||||
retries: "{{ devture_playbook_help_container_retries_count }}"
|
||||
delay: "{{ devture_playbook_help_container_retries_delay }}"
|
||||
until: result is not failed
|
||||
|
||||
- name: Ensure redis paths exist
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
mode: 0700
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_username }}"
|
||||
with_items:
|
||||
- "{{ matrix_redis_base_path }}"
|
||||
- "{{ matrix_redis_data_path }}"
|
||||
|
||||
# We do this as a separate task, because:
|
||||
# - we'd like to do it for the data path only, not for the base path (which contains root-owned environment variable files we'd like to leave as-is)
|
||||
# - we need to do it without `mode`, or we risk making certain `.conf` and other files's executable bit to flip to true
|
||||
- name: Ensure redis data path ownership is correct
|
||||
ansible.builtin.file:
|
||||
path: "{{ matrix_redis_data_path }}"
|
||||
state: directory
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_username }}"
|
||||
recurse: true
|
||||
|
||||
- name: Ensure redis environment variables file created
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/templates/{{ item }}.j2"
|
||||
dest: "{{ matrix_redis_base_path }}/{{ item }}"
|
||||
mode: 0644
|
||||
with_items:
|
||||
- "redis.conf"
|
||||
|
||||
- name: Ensure matrix-redis.service installed
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/templates/systemd/matrix-redis.service.j2"
|
||||
dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-redis.service"
|
||||
mode: 0644
|
||||
register: matrix_redis_systemd_service_result
|
@ -1,31 +0,0 @@
|
||||
---
|
||||
|
||||
- name: Check existence of matrix-redis service
|
||||
ansible.builtin.stat:
|
||||
path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-redis.service"
|
||||
register: matrix_redis_service_stat
|
||||
|
||||
- when: matrix_redis_service_stat.stat.exists | bool
|
||||
block:
|
||||
- name: Ensure matrix-redis is stopped
|
||||
ansible.builtin.service:
|
||||
name: matrix-redis
|
||||
state: stopped
|
||||
enabled: false
|
||||
daemon_reload: true
|
||||
|
||||
- name: Ensure matrix-redis.service doesn't exist
|
||||
ansible.builtin.file:
|
||||
path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-redis.service"
|
||||
state: absent
|
||||
|
||||
- name: Check existence of matrix-redis local data path
|
||||
ansible.builtin.stat:
|
||||
path: "{{ matrix_redis_data_path }}"
|
||||
register: matrix_redis_data_path_stat
|
||||
|
||||
# We just want to notify the user. Deleting data is too destructive.
|
||||
- name: Notify if matrix-redis local data remains
|
||||
ansible.builtin.debug:
|
||||
msg: "Note: You are not using a local redis instance, but some old data remains from before in `{{ matrix_redis_data_path }}`. Feel free to delete it."
|
||||
when: matrix_redis_data_path_stat.stat.exists | bool
|
@ -1,4 +0,0 @@
|
||||
#jinja2: lstrip_blocks: "True"
|
||||
{% if matrix_redis_connection_password %}
|
||||
requirepass {{ matrix_redis_connection_password }}
|
||||
{% endif %}
|
@ -1,37 +0,0 @@
|
||||
#jinja2: lstrip_blocks: "True"
|
||||
[Unit]
|
||||
Description=Matrix Redis server
|
||||
After=docker.service
|
||||
Requires=docker.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStartPre=-/usr/bin/docker stop matrix-redis
|
||||
ExecStartPre=-/usr/bin/docker rm matrix-redis
|
||||
|
||||
ExecStart=/usr/bin/docker run --rm --name matrix-redis \
|
||||
--log-driver=none \
|
||||
--user={{ matrix_user_uid }}:{{ matrix_user_gid }} \
|
||||
--cap-drop=ALL \
|
||||
--read-only \
|
||||
--tmpfs=/tmp:rw,noexec,nosuid,size=100m \
|
||||
--network={{ matrix_docker_network }} \
|
||||
{% if matrix_redis_container_redis_bind_port %}
|
||||
-p {{ matrix_redis_container_redis_bind_port }}:6379 \
|
||||
{% endif %}
|
||||
--mount type=bind,src={{ matrix_redis_base_path }}/redis.conf,dst=/usr/local/etc/redis/redis.conf,ro \
|
||||
--mount type=bind,src={{ matrix_redis_data_path }},dst=/data \
|
||||
{% for arg in matrix_redis_container_extra_arguments %}
|
||||
{{ arg }} \
|
||||
{% endfor %}
|
||||
{{ matrix_redis_docker_image_to_use }} \
|
||||
redis-server /usr/local/etc/redis/redis.conf
|
||||
|
||||
ExecStop=-/usr/bin/docker stop matrix-redis
|
||||
ExecStop=-/usr/bin/docker rm matrix-redis
|
||||
Restart=always
|
||||
RestartSec=30
|
||||
SyslogIdentifier=matrix-redis
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
Loading…
Reference in new issue