mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2024-11-10 06:51:04 +01:00
73 lines
2.1 KiB
YAML
73 lines
2.1 KiB
YAML
- name: Create Docker network for MariaDB
|
|
docker_network:
|
|
name: central_mariadb
|
|
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
|
|
image: mariadb:latest #could lead to problems with nextcloud
|
|
detach: yes
|
|
env:
|
|
MARIADB_ROOT_PASSWORD: "{{central_mariadb_root_password}}"
|
|
MARIADB_AUTO_UPGRADE: "1"
|
|
networks:
|
|
- name: central_mariadb
|
|
volumes:
|
|
- central_mariadb_database:/var/lib/mysql
|
|
published_ports:
|
|
- "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
|
|
restart_policy: unless-stopped
|
|
healthcheck:
|
|
test: "/usr/bin/mariadb --user=root --password={{central_mariadb_root_password}} --execute \"SHOW DATABASES;\""
|
|
interval: 3s
|
|
timeout: 1s
|
|
retries: 5
|
|
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: "{{database_delay}}"
|
|
timeout: 360
|
|
when: run_once_docker_mariadb is not defined
|
|
|
|
- name: "Create database: {{ database_name }}"
|
|
mysql_db:
|
|
name: "{{ database_name }}"
|
|
state: present
|
|
login_user: root
|
|
login_password: "{{ central_mariadb_root_password }}"
|
|
login_host: 127.0.0.1
|
|
login_port: 3306
|
|
|
|
- name: "Create database user: {{ database_username }}"
|
|
mysql_user:
|
|
name: "{{database_username}}"
|
|
password: "{{database_password}}"
|
|
host: "%"
|
|
priv: '{{database_name}}.*:ALL'
|
|
state: present
|
|
login_user: root
|
|
login_password: "{{central_mariadb_root_password}}"
|
|
login_host: 127.0.0.1
|
|
login_port: 3306
|
|
|
|
- name: run the docker_mariadb tasks once
|
|
set_fact:
|
|
run_once_docker_mariadb: true
|
|
when: run_once_docker_mariadb is not defined |