From 3af533a17c6b0121b11c3691c9e556a6285541c2 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Wed, 3 Jan 2024 18:01:58 +0100 Subject: [PATCH] Solved authentification bug and added draft for socket --- roles/docker-mariadb/README.md | 2 +- roles/docker-mariadb/tasks/main.yml | 32 ++++++++++++------- .../templates/docker-compose.yml.j2 | 3 +- ...ocker-compose-volumes-just-database.yml.j2 | 3 ++ 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/roles/docker-mariadb/README.md b/roles/docker-mariadb/README.md index 8926a33b..f30f189d 100644 --- a/roles/docker-mariadb/README.md +++ b/roles/docker-mariadb/README.md @@ -24,4 +24,4 @@ Configure the role by setting the required variables. These can be set in the pl - `database_password`: The password for the database user. ## Contributing -Contributions to this project are welcome. Please submit issues and pull requests with your suggestions. \ No newline at end of file +Contributions to this project are welcome. Please submit issues and pull requests with your suggestions. diff --git a/roles/docker-mariadb/tasks/main.yml b/roles/docker-mariadb/tasks/main.yml index 63150fc8..be91377b 100644 --- a/roles/docker-mariadb/tasks/main.yml +++ b/roles/docker-mariadb/tasks/main.yml @@ -4,6 +4,11 @@ state: present when: run_once_docker_mariadb is not defined +- name: Create a volume for MariaDB socket + docker_volume: + name: mariadb_socket + when: run_once_docker_mariadb is not defined + - name: install MariaDB docker_container: name: central-mariadb @@ -15,39 +20,42 @@ networks: - name: central_mariadb_network volumes: - - database:/var/lib/mysql + - central_mariadb_database:/var/lib/mysql + - central_mariadb_socket:/var/run/mysqld published_ports: - - "127.0.0.1:3306:3306" + - "127.0.0.1:3306:3306" # can be that this will be removed if all applications use sockets command: "--transaction-isolation=READ-COMMITTED --binlog-format=ROW" #for nextcloud when: run_once_docker_mariadb is not defined -- name: wait for availability of mariadb - wait_for: - host: "127.0.0.1" - port: "3306" - delay: 0 - timeout: 120 - when: run_once_docker_mariadb is not defined - - name: install python-mysqlclient pacman: name: python-mysqlclient state: present when: run_once_docker_mariadb is not defined +- name: wait for database + wait_for: + host: 127.0.0.1 + port: 3306 + delay: 10 + timeout: 300 + when: run_once_docker_mariadb is not defined + - name: create database mysql_db: - name: "{{database_databasename}}" + name: "{{ database_databasename }}" state: present login_user: root - login_password: "{{central_mariadb_root_password}}" + login_password: "{{ central_mariadb_root_password }}" login_host: 127.0.0.1 login_port: 3306 + - name: create database user mysql_user: name: "{{database_username}}" password: "{{database_password}}" + host: "%" priv: '{{database_databasename}}.*:ALL' state: present login_user: root diff --git a/roles/docker-yourls/templates/docker-compose.yml.j2 b/roles/docker-yourls/templates/docker-compose.yml.j2 index e1096181..38ae2e87 100644 --- a/roles/docker-yourls/templates/docker-compose.yml.j2 +++ b/roles/docker-yourls/templates/docker-compose.yml.j2 @@ -12,13 +12,14 @@ services: ports: - "127.0.0.1:{{http_port}}:80" environment: - YOURLS_DB_HOST: "{{database_host}}:3306" + YOURLS_DB_HOST: "{{database_host}}" YOURLS_DB_USER: "{{database_username}}" YOURLS_DB_PASS: "{{database_password}}" YOURLS_DB_NAME: "{{database_databasename}}" YOURLS_SITE: "https://{{domain}}" YOURLS_USER: "{{yourls_user}}" YOURLS_PASS: "{{yourls_user_password}}" + {% include 'templates/docker-container-depends-on-just-database.yml.j2' %} {% include 'templates/docker-container-networks.yml.j2' %} diff --git a/templates/docker-compose-volumes-just-database.yml.j2 b/templates/docker-compose-volumes-just-database.yml.j2 index 0e80e052..b243fa25 100644 --- a/templates/docker-compose-volumes-just-database.yml.j2 +++ b/templates/docker-compose-volumes-just-database.yml.j2 @@ -1,5 +1,8 @@ # This needs to be included in docker-compose.yml which just contain a database volume +#volumes: {% if not enable_central_database | bool %} volumes: database: +#{% else %} +# mariadb_socket: {% endif %} \ No newline at end of file