computer-playbook/roles/docker-mariadb/tasks/main.yml

57 lines
1.6 KiB
YAML
Raw Normal View History

2023-12-29 22:50:42 +01:00
- name: Create Docker network for MariaDB
docker_network:
name: central_mariadb_network
2023-12-29 22:50:42 +01:00
state: present
2023-12-29 23:48:44 +01:00
when: run_once_docker_mariadb is not defined
2023-12-29 22:50:42 +01:00
- name: install MariaDB
docker_container:
name: central-mariadb
image: mariadb:latest #could lead to problems with nextcloud
2023-12-29 22:50:42 +01:00
detach: yes
env:
MARIADB_ROOT_PASSWORD: "{{central_mariadb_root_password}}"
MARIADB_AUTO_UPGRADE: "1"
2023-12-29 22:50:42 +01:00
networks:
- name: central_mariadb_network
volumes:
- database:/var/lib/mysql
2023-12-29 22:50:42 +01:00
published_ports:
- "127.0.0.1:3306:3306"
command: "--transaction-isolation=READ-COMMITTED --binlog-format=ROW" #for nextcloud
2023-12-29 23:48:44 +01:00
when: run_once_docker_mariadb is not defined
2023-12-29 22:50:42 +01:00
- 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: create database
mysql_db:
name: "{{database_databasename}}"
state: present
login_user: root
login_password: "{{central_mariadb_root_password}}"
login_host: 127.0.0.1
login_port: 3306
listen: create database
- name: create database user
mysql_user:
name: "{{database_username}}"
password: "{{database_password}}"
priv: '{{database_databasename}}.*:ALL'
state: present
login_user: root
login_password: "{{central_mariadb_root_password}}"
login_host: 127.0.0.1
login_port: 3306
listen: create database
2023-12-29 22:50:42 +01:00
- name: run the docker_mariadb tasks once
set_fact:
2023-12-29 23:48:44 +01:00
run_once_docker_mariadb: true
when: run_once_docker_mariadb is not defined