feat: write custom redis config using inline mod
This commit is contained in:
parent
e3054d1297
commit
aced3188b2
5 changed files with 20 additions and 27 deletions
18
ansible/artifacts/cache/cache.service
vendored
18
ansible/artifacts/cache/cache.service
vendored
|
@ -1,18 +0,0 @@
|
||||||
[Unit]
|
|
||||||
Description=Redis instance with mCaptcha cache module
|
|
||||||
After=network.target
|
|
||||||
Documentation=https://github.com/mCaptcha/cache
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=notify
|
|
||||||
ExecStart=/usr/bin/redis-server /etc/redis/redis.conf --supervised systemd --daemonize no
|
|
||||||
PIDFile=/run/redis/redis-server.pid
|
|
||||||
TimeoutStopSec=0
|
|
||||||
Restart=always
|
|
||||||
User=redis
|
|
||||||
Group=redis
|
|
||||||
RuntimeDirectory=redis
|
|
||||||
RuntimeDirectoryMode=2755
|
|
||||||
|
|
||||||
UMask=007
|
|
||||||
PrivateTmp=true
|
|
2
ansible/artifacts/cache/redis.conf
vendored
2
ansible/artifacts/cache/redis.conf
vendored
|
@ -1,2 +0,0 @@
|
||||||
loadmodule /usr/lib/redis/modules/libcache.so
|
|
||||||
bind 0.0.0.0
|
|
|
@ -6,7 +6,7 @@
|
||||||
ansible.builtin.import_playbook: base.yml
|
ansible.builtin.import_playbook: base.yml
|
||||||
|
|
||||||
- name: Install redis cache
|
- name: Install redis cache
|
||||||
hosts: mcaptcha_demo_server
|
hosts: mcaptcha_hosts
|
||||||
remote_user: atm
|
remote_user: atm
|
||||||
pre_tasks:
|
pre_tasks:
|
||||||
- name: Ensure all VMs are reachable
|
- name: Ensure all VMs are reachable
|
||||||
|
|
1
ansible/roles/cache/handlers/main.yml
vendored
1
ansible/roles/cache/handlers/main.yml
vendored
|
@ -1,5 +1,6 @@
|
||||||
- name: Restart redis
|
- name: Restart redis
|
||||||
listen: restart redis
|
listen: restart redis
|
||||||
|
become: true
|
||||||
ansible.builtin.service:
|
ansible.builtin.service:
|
||||||
name: redis
|
name: redis
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|
24
ansible/roles/cache/tasks/main.yml
vendored
24
ansible/roles/cache/tasks/main.yml
vendored
|
@ -6,11 +6,13 @@
|
||||||
become: true
|
become: true
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
update_cache: true
|
update_cache: true
|
||||||
|
cache_valid_time: 3600
|
||||||
pkg:
|
pkg:
|
||||||
- redis-server
|
- redis-server
|
||||||
|
|
||||||
- name: Create Redis plugins dir
|
- name: Create Redis plugins dir
|
||||||
become: true
|
become: true
|
||||||
|
notify: restart redis
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: /usr/lib/redis/modules
|
path: /usr/lib/redis/modules
|
||||||
owner: redis
|
owner: redis
|
||||||
|
@ -18,15 +20,27 @@
|
||||||
state: directory
|
state: directory
|
||||||
mode: "0755"
|
mode: "0755"
|
||||||
|
|
||||||
|
- name: Load mCaptcha module
|
||||||
|
become: true
|
||||||
|
notify: restart redis
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
dest: /etc/redis/redis.conf
|
||||||
|
line: "{{ item }}"
|
||||||
|
loop:
|
||||||
|
- "loadmodule /usr/lib/redis/modules/libcache.so"
|
||||||
|
- "bind 0.0.0.0"
|
||||||
|
|
||||||
- name: Copy custom Redis configuration
|
- name: Copy custom Redis configuration
|
||||||
become: true
|
become: true
|
||||||
ansible.builtin.copy:
|
notify: restart redis
|
||||||
src: ./artifacts/cache/redis.conf
|
ansible.builtin.file:
|
||||||
dest: /etc/redis/
|
path: "{{ item }}"
|
||||||
owner: redis
|
owner: redis
|
||||||
group: redis
|
group: redis
|
||||||
force: true
|
force: true
|
||||||
mode: "0640"
|
loop:
|
||||||
|
- /etc/redis/redis.conf
|
||||||
|
- /etc/redis/
|
||||||
|
|
||||||
- name: Create download dir
|
- name: Create download dir
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
|
@ -70,5 +84,3 @@
|
||||||
rule: allow
|
rule: allow
|
||||||
proto: tcp
|
proto: tcp
|
||||||
port: "6379"
|
port: "6379"
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue