mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-29 15:06:26 +02:00
Restructured service und web role naming in inventor
This commit is contained in:
30
roles/cmp-rdbms-orchestrator/README.md
Normal file
30
roles/cmp-rdbms-orchestrator/README.md
Normal file
@@ -0,0 +1,30 @@
|
||||
# Central Database
|
||||
|
||||
## 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
|
||||
|
||||
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).
|
||||
|
||||
## Purpose
|
||||
|
||||
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
|
||||
|
||||
- **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.
|
||||
|
||||
## Credits 📝
|
||||
|
||||
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)
|
23
roles/cmp-rdbms-orchestrator/meta/main.yml
Normal file
23
roles/cmp-rdbms-orchestrator/meta/main.yml
Normal 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"
|
16
roles/cmp-rdbms-orchestrator/tasks/main.yml
Normal file
16
roles/cmp-rdbms-orchestrator/tasks/main.yml
Normal file
@@ -0,0 +1,16 @@
|
||||
# The following env file will just be used from the dedicated mariadb container
|
||||
# and not the {{applications.mariadb.hostname }}-database
|
||||
- name: "Create {{database_env}}"
|
||||
template:
|
||||
src: "env/{{database_type}}.env.j2"
|
||||
dest: "{{database_env}}"
|
||||
notify: docker compose up
|
||||
when: not applications | is_feature_enabled('central_database',application_id)
|
||||
|
||||
- name: "Create central database"
|
||||
include_role:
|
||||
name: "svc-rdbms-{{database_type}}"
|
||||
when: applications | is_feature_enabled('central_database',application_id)
|
||||
|
||||
- name: "Add database to backup"
|
||||
include_tasks: "{{ playbook_dir }}/roles/bkp-docker-to-local/tasks/seed-database-to-backup.yml"
|
@@ -0,0 +1,3 @@
|
||||
# Jinja2 configuration template
|
||||
# Define your variables here
|
||||
|
5
roles/cmp-rdbms-orchestrator/templates/env/mariadb.env.j2
vendored
Normal file
5
roles/cmp-rdbms-orchestrator/templates/env/mariadb.env.j2
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
MYSQL_DATABASE="{{database_name}}"
|
||||
MYSQL_USER="{{database_username}}"
|
||||
MYSQL_PASSWORD="{{database_password}}"
|
||||
MYSQL_ROOT_PASSWORD="{{database_password}}"
|
||||
MARIADB_AUTO_UPGRADE="1"
|
4
roles/cmp-rdbms-orchestrator/templates/env/postgres.env.j2
vendored
Normal file
4
roles/cmp-rdbms-orchestrator/templates/env/postgres.env.j2
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
POSTGRES_PASSWORD={{database_password}}
|
||||
POSTGRES_USER={{database_username}}
|
||||
POSTGRES_DB={{database_name}}
|
||||
POSTGRES_INITDB_ARGS=--encoding=UTF8 --locale=C
|
@@ -0,0 +1 @@
|
||||
{% include 'roles/cmp-rdbms-orchestrator/templates/services/' + database_type + '.yml.j2' %}
|
@@ -0,0 +1,22 @@
|
||||
# This template needs to be included in docker-compose.yml, which depend on a mariadb database
|
||||
{% if not applications | is_feature_enabled('central_database',application_id) %}
|
||||
{{ database_host }}:
|
||||
container_name: {{application_id}}-database
|
||||
logging:
|
||||
driver: journald
|
||||
image: mariadb
|
||||
restart: {{docker_restart_policy}}
|
||||
env_file:
|
||||
- {{database_env}}
|
||||
command: "--transaction-isolation=READ-COMMITTED --binlog-format=ROW"
|
||||
volumes:
|
||||
- database:/var/lib/mysql
|
||||
healthcheck:
|
||||
test: [ "CMD", "sh", "-c", "/usr/bin/mariadb --user=$$MYSQL_USER --password=$$MYSQL_PASSWORD --execute 'SHOW DATABASES;'" ]
|
||||
interval: 3s
|
||||
timeout: 1s
|
||||
retries: 5
|
||||
networks:
|
||||
- default
|
||||
{% endif %}
|
||||
{{ "\n" }}
|
@@ -0,0 +1,21 @@
|
||||
# This template needs to be included in docker-compose.yml, which depend on a postgres database
|
||||
{% if not applications | is_feature_enabled('central_database',application_id) %}
|
||||
{{ database_host }}:
|
||||
image: postgres:{{applications.postgres.version}}-alpine
|
||||
container_name: {{application_id}}-database
|
||||
env_file:
|
||||
- {{database_env}}
|
||||
restart: {{docker_restart_policy}}
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U {{database_name}}"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 6
|
||||
volumes:
|
||||
- type: volume
|
||||
source: database
|
||||
target: /var/lib/postgresql/data
|
||||
networks:
|
||||
- default
|
||||
{% endif %}
|
||||
{{ "\n" }}
|
9
roles/cmp-rdbms-orchestrator/vars/database.yml
Normal file
9
roles/cmp-rdbms-orchestrator/vars/database.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
database_instance: "{{ 'central-' + database_type if applications | is_feature_enabled('central_database',database_application_id) else database_application_id }}"
|
||||
database_host: "{{ 'central-' + database_type if applications | is_feature_enabled('central_database',database_application_id) else 'database' }}"
|
||||
database_name: "{{ applications[database_application_id].database.name | default( database_application_id ) }}" # The overwritte configuration is needed by bigbluebutton
|
||||
database_username: "{{ applications[database_application_id].database.username | default( database_application_id )}}" # The overwritte configuration is needed by bigbluebutton
|
||||
database_password: "{{ applications[database_application_id].credentials.database_password }}"
|
||||
database_port: "{{ 3306 if database_type == 'mariadb' else applications.postgres.port }}"
|
||||
database_env: "{{docker_compose.directories.env}}{{database_type}}.env"
|
||||
database_url_jdbc: "jdbc:{{ database_type if database_type == 'mariadb' else 'postgresql' }}://{{ database_host }}:{{ database_port }}/{{ database_name }}"
|
||||
database_url_full: "{{database_type}}://{{database_username}}:{{database_password}}@{{database_host}}:{{database_port}}/{{ database_name }}"
|
Reference in New Issue
Block a user