Skip to content
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

migrate redis installation from rpm to container-based #63

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions roles/redis/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
redis_image: docker.io/redis:6
24 changes: 18 additions & 6 deletions roles/redis/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
---
- name: Install redis
ansible.builtin.package:
name: "redis"
- name: Pull Redis container image
containers.podman.podman_image:
name: "{{ redis_image }}"
state: present

- name: Start the Redis Service
ansible.builtin.systemd:
- name: Create directory for Redis data
ansible.builtin.file:
path: /var/lib/redis
state: directory
owner: 1001
group: 1001
mode: '0755'

- name: Run Redis as a container
containers.podman.podman_container:
name: redis
enabled: true
image: "{{ redis_image }}"
state: started
volumes:
- /var/lib/redis:/data:Z
ports:
- "6379:6379"

- name: Wait for Redis service to be accessible
ansible.builtin.wait_for:
Expand Down
3 changes: 0 additions & 3 deletions tests/redis_test.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import pytest


REDIS_HOST = 'localhost'
REDIS_PORT = 6379


def test_redis_service(server):
redis = server.service("redis")
assert redis.is_running
assert redis.is_enabled


def test_redis_port(server):
redis = server.addr(REDIS_HOST)
assert redis.port(REDIS_PORT).is_reachable
Loading