Create redis role
This commit is contained in:
parent
330c7d64df
commit
74baf5680f
9 changed files with 99 additions and 79 deletions
|
@ -1,5 +0,0 @@
|
|||
save ""
|
||||
appendonly no
|
||||
|
||||
maxmemory 32mb
|
||||
maxmemory-policy allkeys-lru
|
|
@ -1,38 +0,0 @@
|
|||
---
|
||||
- name: Create forgejo volume
|
||||
become: true
|
||||
community.docker.docker_volume:
|
||||
name: forgejo
|
||||
- name: Copy app.ini
|
||||
become: true
|
||||
ansible.builtin.template:
|
||||
src: app.ini.j2
|
||||
dest: /var/lib/docker/volumes/forgejo/_data/custom/conf/app.ini
|
||||
owner: 1000
|
||||
group: 1000
|
||||
mode: '0660'
|
||||
register: appini
|
||||
- name: Create forgejo container
|
||||
become: true
|
||||
community.docker.docker_container:
|
||||
name: forgejo
|
||||
image: codeberg.org/forgejo/forgejo:8.0.3
|
||||
env:
|
||||
USER_UID: "1000"
|
||||
USER_GID: "1000"
|
||||
FORGEJO_WORK_DIR: "/data"
|
||||
FORGEJO_CUSTOM: "/data/custom"
|
||||
networks:
|
||||
- name: postgresql
|
||||
- name: redis-forgejo
|
||||
- name: minio
|
||||
- name: haproxy
|
||||
volumes:
|
||||
- forgejo:/data
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
ports:
|
||||
- "127.0.0.1:3004:3000"
|
||||
- "8022:8022"
|
||||
restart_policy: unless-stopped
|
||||
recreate: "{{ appini.changed }}"
|
|
@ -1,3 +1,49 @@
|
|||
---
|
||||
- import_tasks: redis.yml
|
||||
- import_tasks: forgejo.yml
|
||||
- name: Create forgejo network
|
||||
become: true
|
||||
community.docker.docker_network:
|
||||
name: forgejo
|
||||
- name: Create redis container
|
||||
include_role:
|
||||
name: redis
|
||||
vars:
|
||||
preset: cache
|
||||
container_name: redis-forgejo
|
||||
docker_networks:
|
||||
- name: forgejo
|
||||
- name: Create forgejo volume
|
||||
become: true
|
||||
community.docker.docker_volume:
|
||||
name: forgejo
|
||||
- name: Copy app.ini
|
||||
become: true
|
||||
ansible.builtin.template:
|
||||
src: app.ini.j2
|
||||
dest: /var/lib/docker/volumes/forgejo/_data/custom/conf/app.ini
|
||||
owner: 1000
|
||||
group: 1000
|
||||
mode: '0660'
|
||||
register: appini
|
||||
- name: Create forgejo container
|
||||
become: true
|
||||
community.docker.docker_container:
|
||||
name: forgejo
|
||||
image: codeberg.org/forgejo/forgejo:8.0.3
|
||||
env:
|
||||
USER_UID: "1000"
|
||||
USER_GID: "1000"
|
||||
FORGEJO_WORK_DIR: "/data"
|
||||
FORGEJO_CUSTOM: "/data/custom"
|
||||
networks:
|
||||
- name: postgresql
|
||||
- name: forgejo
|
||||
- name: minio
|
||||
- name: haproxy
|
||||
volumes:
|
||||
- forgejo:/data
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
ports:
|
||||
- "8022:8022"
|
||||
restart_policy: unless-stopped
|
||||
recreate: "{{ appini.changed }}"
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
---
|
||||
- name: Create redis-forgejo network
|
||||
become: true
|
||||
community.docker.docker_network:
|
||||
name: redis-forgejo
|
||||
- name: Create redis-forgejo config dir
|
||||
become: true
|
||||
ansible.builtin.file:
|
||||
path: /etc/redis/forgejo
|
||||
state: directory
|
||||
mode: '1755'
|
||||
owner: root
|
||||
group: root
|
||||
- name: Copy redis config
|
||||
become: true
|
||||
ansible.builtin.copy:
|
||||
src: redis.conf
|
||||
dest: /etc/redis/forgejo/redis.conf
|
||||
mode: '0664'
|
||||
owner: root
|
||||
group: root
|
||||
register: redisconf
|
||||
- name: Create redis container
|
||||
become: true
|
||||
community.docker.docker_container:
|
||||
name: redis-forgejo
|
||||
image: redis:7.4-bookworm
|
||||
command: ["redis-server", "/etc/redis/redis.conf"]
|
||||
volumes:
|
||||
- /etc/redis/forgejo:/etc/redis:ro
|
||||
networks:
|
||||
- name: redis-forgejo
|
||||
restart_policy: unless-stopped
|
||||
recreate: "{{ redisconf.changed }}"
|
20
roles/redis/meta/argument_specs.yml
Normal file
20
roles/redis/meta/argument_specs.yml
Normal file
|
@ -0,0 +1,20 @@
|
|||
---
|
||||
argument_specs:
|
||||
main:
|
||||
options:
|
||||
preset:
|
||||
description: "Select 'persistent' preset if you want to save data."
|
||||
type: "str"
|
||||
choices:
|
||||
- persistent
|
||||
- cache
|
||||
required: true
|
||||
container_name:
|
||||
type: "str"
|
||||
required: true
|
||||
docker_networks:
|
||||
type: "list"
|
||||
required: true
|
||||
docker_volume:
|
||||
type: "str"
|
||||
description: "Required for 'persistent' preset"
|
9
roles/redis/tasks/cache.yml
Normal file
9
roles/redis/tasks/cache.yml
Normal file
|
@ -0,0 +1,9 @@
|
|||
---
|
||||
- name: Run redis container
|
||||
become: true
|
||||
community.docker.docker_container:
|
||||
name: "{{ container_name }}"
|
||||
image: "{{ image }}"
|
||||
command: "{{ shared_cmd + ['--save', '', '--maxmemory', '128mb', '--maxmemory-policy', 'allkeys-lru'] }}"
|
||||
networks: "{{ docker_networks }}"
|
||||
restart_policy: unless-stopped
|
5
roles/redis/tasks/main.yml
Normal file
5
roles/redis/tasks/main.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
- import_tasks: persistent.yml
|
||||
when: preset == "persistent"
|
||||
- import_tasks: cache.yml
|
||||
when: preset == "cache"
|
15
roles/redis/tasks/persistent.yml
Normal file
15
roles/redis/tasks/persistent.yml
Normal file
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
- name: Create docker volume
|
||||
become: true
|
||||
community.docker.docker_volume:
|
||||
name: "{{ docker_volume }}"
|
||||
- name: Run redis container
|
||||
become: true
|
||||
community.docker.docker_container:
|
||||
name: "{{ container_name }}"
|
||||
image: "{{ image }}"
|
||||
command: "{{ shared_cmd }}"
|
||||
networks: "{{ docker_networks }}"
|
||||
volumes:
|
||||
- "{{ docker_volume }}:/data"
|
||||
restart_policy: unless-stopped
|
2
roles/redis/vars/main.yml
Normal file
2
roles/redis/vars/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
image: redis:7.4-bookworm
|
||||
shared_cmd: ["redis-server", "--loglevel", "warning"]
|
Loading…
Reference in a new issue