wip-cache #2
3 changed files with 82 additions and 78 deletions
|
@ -11,81 +11,5 @@
|
||||||
pre_tasks:
|
pre_tasks:
|
||||||
- name: Ensure all VMs are reachable
|
- name: Ensure all VMs are reachable
|
||||||
ansible.builtin.ping:
|
ansible.builtin.ping:
|
||||||
|
roles:
|
||||||
tasks:
|
- cache
|
||||||
- name: Install redis-server
|
|
||||||
become: true
|
|
||||||
ansible.builtin.apt:
|
|
||||||
update_cache: true
|
|
||||||
pkg:
|
|
||||||
- redis-server
|
|
||||||
|
|
||||||
- name: Create Redis plugins dir
|
|
||||||
become: true
|
|
||||||
ansible.builtin.file:
|
|
||||||
path: /usr/lib/redis/modules
|
|
||||||
owner: redis
|
|
||||||
group: redis
|
|
||||||
state: directory
|
|
||||||
mode: "0755"
|
|
||||||
|
|
||||||
- name: Copy custom Redis configuration
|
|
||||||
become: true
|
|
||||||
ansible.builtin.copy:
|
|
||||||
src: ./artifacts/cache/redis.conf
|
|
||||||
dest: /etc/redis/
|
|
||||||
owner: redis
|
|
||||||
group: redis
|
|
||||||
force: true
|
|
||||||
mode: "0640"
|
|
||||||
|
|
||||||
- name: Create download dir
|
|
||||||
ansible.builtin.file:
|
|
||||||
path: /tmp/cache-lib
|
|
||||||
state: directory
|
|
||||||
mode: "0755"
|
|
||||||
|
|
||||||
- name: Download plugin
|
|
||||||
ansible.builtin.get_url:
|
|
||||||
url: https://dl.mcaptcha.org/mcaptcha/cache/master/cache-master-linux-amd64.tar.gz
|
|
||||||
dest: /tmp/cache-lib/
|
|
||||||
checksum: sha256:https://dl.mcaptcha.org/mcaptcha/cache/master/cache-master-linux-amd64.tar.gz.sha256
|
|
||||||
|
|
||||||
- name: Extract cache-master-linux-amd64.tar.gz into /var/lib/foo
|
|
||||||
ansible.builtin.unarchive:
|
|
||||||
src: /tmp/cache-lib/cache-master-linux-amd64.tar.gz
|
|
||||||
remote_src: true
|
|
||||||
dest: /tmp/cache-lib/
|
|
||||||
|
|
||||||
- name: Copy custom Redis configuration
|
|
||||||
become: true
|
|
||||||
notify: restart redis
|
|
||||||
ansible.builtin.copy:
|
|
||||||
src: /tmp/cache-lib/cache-master-linux-amd64/libcache.so
|
|
||||||
remote_src: true
|
|
||||||
dest: /usr/lib/redis/modules/
|
|
||||||
owner: redis
|
|
||||||
group: redis
|
|
||||||
force: true
|
|
||||||
mode: "0755"
|
|
||||||
|
|
||||||
# - name: Delete download dir
|
|
||||||
# ansible.builtin.file:
|
|
||||||
# path: /tmp/cache-lib
|
|
||||||
# state: absent
|
|
||||||
|
|
||||||
- name: Allow port 6379 for redis
|
|
||||||
become: true
|
|
||||||
community.general.ufw:
|
|
||||||
state: enabled
|
|
||||||
rule: allow
|
|
||||||
proto: tcp
|
|
||||||
port: "6379"
|
|
||||||
|
|
||||||
handlers:
|
|
||||||
- name: Restart redis
|
|
||||||
listen: restart redis
|
|
||||||
ansible.builtin.service:
|
|
||||||
name: redis
|
|
||||||
enabled: true
|
|
||||||
state: restarted
|
|
||||||
|
|
6
ansible/roles/cache/handlers/main.yml
vendored
Normal file
6
ansible/roles/cache/handlers/main.yml
vendored
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
- name: Restart redis
|
||||||
|
listen: restart redis
|
||||||
|
ansible.builtin.service:
|
||||||
|
name: redis
|
||||||
|
enabled: true
|
||||||
|
state: restarted
|
74
ansible/roles/cache/tasks/main.yml
vendored
Normal file
74
ansible/roles/cache/tasks/main.yml
vendored
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
# SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
---
|
||||||
|
- name: Install redis-server
|
||||||
|
become: true
|
||||||
|
ansible.builtin.apt:
|
||||||
|
update_cache: true
|
||||||
|
pkg:
|
||||||
|
- redis-server
|
||||||
|
|
||||||
|
- name: Create Redis plugins dir
|
||||||
|
become: true
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /usr/lib/redis/modules
|
||||||
|
owner: redis
|
||||||
|
group: redis
|
||||||
|
state: directory
|
||||||
|
mode: "0755"
|
||||||
|
|
||||||
|
- name: Copy custom Redis configuration
|
||||||
|
become: true
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: ./artifacts/cache/redis.conf
|
||||||
|
dest: /etc/redis/
|
||||||
|
owner: redis
|
||||||
|
group: redis
|
||||||
|
force: true
|
||||||
|
mode: "0640"
|
||||||
|
|
||||||
|
- name: Create download dir
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /tmp/cache-lib
|
||||||
|
state: directory
|
||||||
|
mode: "0755"
|
||||||
|
|
||||||
|
- name: Download plugin
|
||||||
|
ansible.builtin.get_url:
|
||||||
|
url: https://dl.mcaptcha.org/mcaptcha/cache/master/cache-master-linux-amd64.tar.gz
|
||||||
|
dest: /tmp/cache-lib/
|
||||||
|
checksum: sha256:https://dl.mcaptcha.org/mcaptcha/cache/master/cache-master-linux-amd64.tar.gz.sha256
|
||||||
|
|
||||||
|
- name: Extract cache-master-linux-amd64.tar.gz into /var/lib/foo
|
||||||
|
ansible.builtin.unarchive:
|
||||||
|
src: /tmp/cache-lib/cache-master-linux-amd64.tar.gz
|
||||||
|
remote_src: true
|
||||||
|
dest: /tmp/cache-lib/
|
||||||
|
|
||||||
|
- name: Copy custom Redis configuration
|
||||||
|
become: true
|
||||||
|
notify: restart redis
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: /tmp/cache-lib/cache-master-linux-amd64/libcache.so
|
||||||
|
remote_src: true
|
||||||
|
dest: /usr/lib/redis/modules/
|
||||||
|
owner: redis
|
||||||
|
group: redis
|
||||||
|
force: true
|
||||||
|
mode: "0755"
|
||||||
|
|
||||||
|
# - name: Delete download dir
|
||||||
|
# ansible.builtin.file:
|
||||||
|
# path: /tmp/cache-lib
|
||||||
|
# state: absent
|
||||||
|
|
||||||
|
- name: Allow port 6379 for redis
|
||||||
|
become: true
|
||||||
|
community.general.ufw:
|
||||||
|
state: enabled
|
||||||
|
rule: allow
|
||||||
|
proto: tcp
|
||||||
|
port: "6379"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue