Implemented README.md's und meta/main.yml and solved bugs

This commit is contained in:
2025-04-08 12:55:53 +02:00
parent a13bd1883e
commit adecee43ec
8 changed files with 98 additions and 93 deletions

View File

@@ -1,71 +1,30 @@
# Database Setup Role 🚀
# Docker Central Database 🐳
This Ansible role provides the necessary tasks, files, templates, and variables to set up databases in your Docker Compose environment. It is essential for configuring your application's database, whether using a local or a central instance of **MariaDB** or **PostgreSQL**.
## Description
---
This Ansible role provisions a centralized database system in your Docker Compose environment. It supports both MariaDB and PostgreSQL, providing a robust, scalable, and low-maintenance database solution. Whether you're consolidating your application's data or creating a dedicated central storage, this role simplifies setup and integration.
## Overview
- **Database Variables**
Defined in [./vars/database.yml](./vars/database.yml), these variables include:
- `database_instance`
- `database_host`
- `database_name`
- `database_username`
- `database_port`
- `database_env`
Tailored for environments that require a central data repository, this role:
- Loads necessary database variables defined in [vars/database.yml](./vars/database.yml).
- Generates an environment file based on the chosen database engine.
- Integrates seamlessly with Docker Compose to deploy a centralized database container (if enabled).
- **Tasks**
Located in [./tasks/main.yml](./tasks/main.yml), the tasks perform the following:
- Include the Docker Compose role.
- Load database variables.
- Create the environment file for the chosen database from a template.
- Optionally create a central database (if enabled).
## Purpose
- **Templates**
- **Environment Files:**
- [PostgreSQL Environment Template](./templates/env/postgres.env.j2)
- [MariaDB Environment Template](./templates/env/mariadb.env.j2)
- **Service Files:**
- [MariaDB Service Template](./templates/services/mariadb.yml.j2)
- [PostgreSQL Service Template](./templates/services/postgres.yml.j2)
The role's purpose is to automate the provisioning and configuration of a centralized database service. This not only reduces manual setup but also ensures consistent, reliable deployment across production and homelab environments.
---
## Features
## Usage 📋
- **Supports Multiple Engines:** Easily switch between MariaDB and PostgreSQL.
- **Centralized Data Management:** Improves data consistency and security.
- **Docker Compose Integration:** Automates container setup and configuration.
- **Simplified Variable Management:** Preconfigured templates minimize manual intervention.
To use this role, include it in your playbook as follows:
## Credits 📝
```yaml
- hosts: all
roles:
- your_database_role_name
```
When executed, the role will:
1. Load database configuration variables.
2. Generate the appropriate environment file for the database.
3. Incorporate the Docker Compose routines.
4. Create a central database if `applications[application_id].database.central_storage` is set to `true`.
---
## Author
Developed by [Kevin Veen-Birkenbach](https://www.veen.world/) 💻🌐
---
## Acknowledgments & ChatGPT Conversations 🤖💬
This role was created with the assistance of ChatGPT. The following ChatGPT conversations helped shape the design and implementation of this role:
- https://chatgpt.com/share/67a23d18-fb54-800f-983c-d6d00752b0b4
- https://chatgpt.com/share/67a244bb-11e4-800f-980f-5ef0e8b109d7
Feel free to explore these discussions for insights into design decisions and implementation details.
---
Happy automating! 🎉
Developed and maintained by **Kevin Veen-Birkenbach**.
Learn more at [www.veen.world](https://www.veen.world)
Part of the [CyMaIS Project](https://github.com/kevinveenbirkenbach/cymais)
License: [CyMaIS NonCommercial License (CNCL)](https://s.veen.world/cncl)

View File

@@ -0,0 +1,23 @@
---
galaxy_info:
author: "Kevin Veen-Birkenbach"
description: >-
The Docker Central Database Role lets you quickly provision a centralized database through Docker Compose.
Whether using MariaDB or PostgreSQL, this role provides a reliable, low-maintenance solution that supports your business applications.
license: "CyMaIS NonCommercial License (CNCL)"
license_url: "https://s.veen.world/cncl"
company: "Kevin Veen-Birkenbach Consulting & Coaching Solutions"
min_ansible_version: "2.9"
platforms:
- name: Docker
versions:
- "latest"
galaxy_tags:
- database
- docker
- mariadb
- postgresql
- central-database
repository: "https://s.veen.world/cymais"
issue_tracker_url: "https://s.veen.world/cymaisissues"
documentation: "https://s.veen.world/cymais"

View File

@@ -1,7 +1,7 @@
# This template needs to be included in docker-compose.yml, which depend on a postgres database
{% if not applications[application_id].database.central_storage | bool %}
database:
image: postgres:{{applications.postgres.database_version}}-alpine
image: postgres:{{applications.postgres.version}}-alpine
container_name: {{application_id}}-database
env_file:
- {{database_env}}