44 lines
1.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Role: docker-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/)