Renamed redis role

This commit is contained in:
2025-07-12 17:58:04 +02:00
parent e2b5491e1f
commit 46bba3564d
5 changed files with 3 additions and 3 deletions

View File

@@ -0,0 +1,43 @@
# Role: svc-db-redis
## Description
This Ansible role provides a Jinja2 snippet to inject a Redis service definition into your Docker Compose setup. It renders a `service.yml.j2` template that defines a `redis` container with sensible defaults.
## Overview
The roles `service.yml.j2` template includes:
- An Alpine-based Redis image (`redis:alpine`)
- Container naming based on `application_id` (defaults to `redis`)
- Restart policy
- Journald logging driver
- A named volume (`redis:/data`) for persistence
- A basic healthcheck using `redis-cli ping`
- Attachment to the default network
Include this snippet in your top-level `docker-compose.yml.j2` where you want Redis to appear.
## Features
- **Configurable `application_id`**
Sets container name (`{{ application_id }}-redis`).
- **Restart policy**
Controlled by `docker_restart_policy`.
- **Journald logging**
Ensures logs are captured by systemds journal.
- **Persistent storage**
Declares and mounts `redis:/data`.
- **Built-in healthcheck**
Uses `redis-cli ping` with configurable intervals and retries.
## Further Resources
- [Official Redis Docker image on Docker Hub](https://hub.docker.com/_/redis)
- [Ansible Jinja2 documentation](https://docs.ansible.com/ansible/latest/user_guide/playbooks_templating.html)
- [Docker Compose reference](https://docs.docker.com/compose/compose-file/)

View File

@@ -0,0 +1,23 @@
---
galaxy_info:
author: "Kevin Veen-Birchenbach"
description: "Provides a Docker Compose snippet for a Redis service (redis:alpine) with volume, healthcheck and logging."
license: "CyMaIS NonCommercial License (CNCL)"
license_url: "https://s.veen.world/cncl"
company: |
Kevin Veen-Birchenbach
Consulting & Coaching Solutions
https://www.veen.world
galaxy_tags:
- redis
- docker
- cache
repository: "https://github.com/kevinveenbirkenbach/cymais"
issue_tracker_url: "https://github.com/kevinveenbirkenbach/cymais/issues"
documentation: "https://github.com/kevinveenbirkenbach/cymais/tree/main/roles/svc-db-redis"
min_ansible_version: "2.9"
platforms:
- name: Any
versions: [ all ]
dependencies: []

View File

@@ -0,0 +1,17 @@
# This template needs to be included in docker-compose.yml, which depend on redis
redis:
image: redis:alpine
container_name: {{application_id}}-redis
restart: {{docker_restart_policy}}
logging:
driver: journald
volumes:
- redis:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 1s
timeout: 3s
retries: 30
networks:
- default
{{ "\n" }}

View File

@@ -0,0 +1 @@
application_id: redis