mirror of
				https://github.com/kevinveenbirkenbach/computer-playbook.git
				synced 2025-11-04 04:08:15 +00:00 
			
		
		
		
	Implemented README.md's und meta/main.yml and solved bugs
This commit is contained in:
		@@ -496,7 +496,7 @@ defaults_applications:
 | 
			
		||||
        enabled: false
 | 
			
		||||
      integration_gitlab:
 | 
			
		||||
        # Nextcloud Integration GitLab: connects Nextcloud with GitLab repositories (https://apps.nextcloud.com/apps/integration_gitlab)
 | 
			
		||||
        enabled: "{{ 'gitlab' in group_names in group_names | lower }}"
 | 
			
		||||
        enabled: "{{ 'gitlab' in group_names | lower }}"
 | 
			
		||||
      integration_github:
 | 
			
		||||
        # Nextcloud Integration GitHub: integrates GitHub repositories with Nextcloud (https://apps.nextcloud.com/apps/integration_github)
 | 
			
		||||
        enabled: false
 | 
			
		||||
@@ -694,7 +694,7 @@ defaults_applications:
 | 
			
		||||
  ## Postgres
 | 
			
		||||
  # Please set an version in your inventory file - Rolling release for postgres isn't recommended
 | 
			
		||||
  postgres:
 | 
			
		||||
    database.version:  "latest"
 | 
			
		||||
    version:                      "latest"
 | 
			
		||||
 | 
			
		||||
  portfolio:
 | 
			
		||||
    database:
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										23
									
								
								roles/docker-central-database/meta/main.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								roles/docker-central-database/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"
 | 
			
		||||
@@ -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}}
 | 
			
		||||
 
 | 
			
		||||
@@ -4,7 +4,7 @@
 | 
			
		||||
  listen: "Import LDIF files"
 | 
			
		||||
  # @todo Remove the following ignore errors when setting up a new server
 | 
			
		||||
  # Just here because debugging would take to much time
 | 
			
		||||
  ignore_errors: true
 | 
			
		||||
  # ignore_errors: true
 | 
			
		||||
 | 
			
		||||
- name: Refint Module Activation for OpenLDAP
 | 
			
		||||
  shell: >
 | 
			
		||||
@@ -14,17 +14,17 @@
 | 
			
		||||
  failed_when: ldapadd_result.rc not in [0, 68]
 | 
			
		||||
  # @todo Remove the following ignore errors when setting up a new server
 | 
			
		||||
  # Just here because debugging would take to much time
 | 
			
		||||
  ignore_errors: true
 | 
			
		||||
  # ignore_errors: true
 | 
			
		||||
 | 
			
		||||
- name: Refint Overlay Configuration for OpenLDAP
 | 
			
		||||
  shell: >
 | 
			
		||||
    docker exec -i openldap modify -Y EXTERNAL -H ldapi:/// -f {{ldif_docker_path}}02_member_of_configuration.ldif
 | 
			
		||||
    docker exec -i openldap ldapmodify -Y EXTERNAL -H ldapi:/// -f {{ldif_docker_path}}03_member_of_configuration.ldif
 | 
			
		||||
  listen: "Import LDIF files"
 | 
			
		||||
  register: ldapadd_result
 | 
			
		||||
  failed_when: ldapadd_result.rc not in [0, 68]
 | 
			
		||||
  # @todo Remove the following ignore errors when setting up a new server
 | 
			
		||||
  # Just here because debugging would take to much time
 | 
			
		||||
  ignore_errors: true
 | 
			
		||||
  # ignore_errors: true
 | 
			
		||||
 | 
			
		||||
- name: "Import users, groups, etc. to LDAP"
 | 
			
		||||
  shell: >
 | 
			
		||||
 
 | 
			
		||||
@@ -1,30 +1,30 @@
 | 
			
		||||
# Docker-Postgres Ansible Role
 | 
			
		||||
# PostgreSQL 🐳
 | 
			
		||||
 | 
			
		||||
## Description
 | 
			
		||||
 | 
			
		||||
This Ansible role deploys and configures a PostgreSQL database in a Docker container using Docker Compose. It is designed to simplify database administration by automating the creation of networks, containers, and essential database tasks (such as database and user creation) for a secure and high-performance environment.
 | 
			
		||||
 | 
			
		||||
## Overview
 | 
			
		||||
This Ansible role is designed to deploy a PostgreSQL database using Docker. It includes tasks for setting up a Docker network, installing PostgreSQL in a Docker container, and initializing the database with a specified user and database.
 | 
			
		||||
 | 
			
		||||
## Role Variables
 | 
			
		||||
- `central_postgres_password`: The password for the PostgreSQL superuser (`postgres`).
 | 
			
		||||
- `database_name`: Name of the database to be created.
 | 
			
		||||
- `database_username`: Username for the database user.
 | 
			
		||||
- `database_password`: Password for the database user.
 | 
			
		||||
Built for environments that demand reliability and ease of management, this role:
 | 
			
		||||
- Sets up a dedicated Docker network for PostgreSQL.
 | 
			
		||||
- Deploys a PostgreSQL container with secure configurations and automated healthchecks.
 | 
			
		||||
- Automates tasks like database creation, user setup, and privilege assignments to streamline your workflows.
 | 
			
		||||
 | 
			
		||||
## Role Tasks
 | 
			
		||||
1. **Create Docker network for PostgreSQL**: Sets up a Docker network for PostgreSQL communication.
 | 
			
		||||
2. **Install PostgreSQL**: Deploys PostgreSQL in a Docker container, attaching it to the created network and setting the superuser password.
 | 
			
		||||
3. **Run the docker_postgres tasks once**: Ensures that the tasks are only run once to avoid redundancy.
 | 
			
		||||
## Purpose
 | 
			
		||||
 | 
			
		||||
## Handlers
 | 
			
		||||
- **Create database**: Creates a new database with the specified name.
 | 
			
		||||
- **Create database user**: Sets up a user with full privileges on the newly created database.
 | 
			
		||||
The purpose of this role is to provide an effortless way to deploy a PostgreSQL database via Docker. It minimizes manual interventions while ensuring that your database is configured securely and reliably for both production and development scenarios.
 | 
			
		||||
 | 
			
		||||
## Usage
 | 
			
		||||
1. Set the required variables in your playbook or inventory file.
 | 
			
		||||
2. Include this role in your playbook.
 | 
			
		||||
3. Run the playbook against the target host.
 | 
			
		||||
## Features
 | 
			
		||||
 | 
			
		||||
## Notes
 | 
			
		||||
- The PostgreSQL server is bound to `127.0.0.1:5432` on the host machine, making it accessible only from localhost.
 | 
			
		||||
- **Automated Deployment:** Installs PostgreSQL with minimal manual steps.
 | 
			
		||||
- **Robust Administration:** Automatically creates databases, users, and assigns privileges.
 | 
			
		||||
- **Enhanced Security:** The service is bound to `127.0.0.1:5432`, restricting access and enhancing security.
 | 
			
		||||
- **Seamless Docker Integration:** Works harmoniously with Docker Compose and other roles in your infrastructure.
 | 
			
		||||
 | 
			
		||||
## Author
 | 
			
		||||
This role was created by [Kevin Veen-Birkenbach](https://www.veen.world).
 | 
			
		||||
## Credits 📝
 | 
			
		||||
 | 
			
		||||
Developed by **Kevin Veen-Birkenbach**.  
 | 
			
		||||
Discover 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/docker-postgres/meta/main.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								roles/docker-postgres/meta/main.yml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,23 @@
 | 
			
		||||
---
 | 
			
		||||
galaxy_info:
 | 
			
		||||
  author: "Kevin Veen-Birkenbach"
 | 
			
		||||
  description: >-
 | 
			
		||||
    The Docker PostgreSQL Role offers an easy and efficient way to run a PostgreSQL database inside a Docker container.
 | 
			
		||||
    Manage your data securely and effectively, making it ideal for production or local development.
 | 
			
		||||
  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:
 | 
			
		||||
    - postgresql
 | 
			
		||||
    - docker
 | 
			
		||||
    - database
 | 
			
		||||
    - administration
 | 
			
		||||
    - central-database
 | 
			
		||||
  repository: "https://s.veen.world/cymais"
 | 
			
		||||
  issue_tracker_url: "https://s.veen.world/cymaisissues"
 | 
			
		||||
  documentation: "https://s.veen.world/cymais"
 | 
			
		||||
@@ -9,7 +9,7 @@
 | 
			
		||||
- name: Install PostgreSQL
 | 
			
		||||
  docker_container:
 | 
			
		||||
    name: central-postgres
 | 
			
		||||
    image: "postgres:{{applications.postgres.database_version}}"
 | 
			
		||||
    image: "postgres:{{applications.postgres.version}}"
 | 
			
		||||
    detach: yes
 | 
			
		||||
    env:
 | 
			
		||||
      POSTGRES_PASSWORD: "{{ central_postgres_password }}"
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user