Restructuring for new backup solution

This commit is contained in:
2025-07-16 19:09:31 +02:00
parent dea2669de2
commit 169493179e
38 changed files with 133 additions and 91 deletions

View File

@@ -2,5 +2,6 @@
## Execute SQL commands
```bash
docker exec -it {{applications['mariadb'].hostname }} mariadb -u root -p
# Assume the container name is mariadb
docker exec -it mariadb mariadb -u root -p
```

View File

@@ -1,8 +1,11 @@
hostname: "svc-db-mariadb"
network: "<< defaults_applications[svc-db-mariadb].hostname >>"
docker:
docker:
services:
mariadb:
version: "latest"
image: "mariadb"
volume: "<< defaults_applications[svc-db-mariadb].hostname >>_data"
mariadb:
version: "latest"
image: "mariadb"
name: "mariadb"
backup:
datase_routine: true
network: "mariadb"
volumes:
data: "mariadb_data"

View File

@@ -25,6 +25,6 @@
# @todo Remove if this works fine in the future.
#- name: Grant database privileges
# ansible.builtin.shell:
# cmd: "docker exec {{mariadb_hostname }} mariadb -u root -p{{ mariadb_root_pwd }} -e \"GRANT ALL PRIVILEGES ON `{{database_name}}`.* TO '{{database_username}}'@'%';\""
# cmd: "docker exec {{mariadb_name }} mariadb -u root -p{{ mariadb_root_pwd }} -e \"GRANT ALL PRIVILEGES ON `{{database_name}}`.* TO '{{database_username}}'@'%';\""
# args:
# executable: /bin/bash

View File

@@ -8,7 +8,7 @@
- name: install MariaDB
docker_container:
name: "{{ mariadb_hostname }}"
name: "{{ mariadb_name }}"
image: "{{ mariadb_image }}:{{ mariadb_version}}"
detach: yes
env:
@@ -36,9 +36,9 @@
state: present
when: run_once_docker_mariadb is not defined
- name: "Wait until the MariaDB container with hostname '{{ mariadb_hostname }}' is healthy"
- name: "Wait until the MariaDB container with hostname '{{ mariadb_name }}' is healthy"
community.docker.docker_container_info:
name: "{{ mariadb_hostname }}"
name: "{{ mariadb_name }}"
register: db_info
until:
- db_info.containers is defined

View File

@@ -1,11 +1,10 @@
application_id: svc-db-mariadb
mariadb_hostname: "{{ applications | get_app_conf(application_id,'hostname', True) }}"
mariadb_root_pwd: "{{ applications | get_app_conf(application_id,'credentials.root_password', True) }}"
mariadb_init: "{{ database_username is defined and database_password is defined and database_name is defined }}"
mariadb_subnet: "{{ networks.local['svc-db-mariadb'].subnet }}"
mariadb_network_name: "{{ applications | get_app_conf(application_id,'network', True) }}"
mariadb_volume: "{{ applications | get_app_conf(application_id,'docker.services.mariadb.volume', True) }}"
mariadb_volume: "{{ applications | get_app_conf(application_id,'docker.volumes.data', True) }}"
mariadb_image: "{{ applications | get_app_conf(application_id,'docker.services.mariadb.image','mariadb', True) }}"
mariadb_version: "{{ applications | get_app_conf(application_id,'docker.services.mariadb.version', True) }}"
mariadb_name: "{{ applications | get_app_conf(application_id,'docker.services.mariadb.name', True) }}"
mariadb_port: "{{ database_port | default(ports.localhost.database[ application_id ]) }}"