mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-07-17 14:04:24 +02:00
61 lines
2.0 KiB
YAML
61 lines
2.0 KiB
YAML
- name: Create Docker network for MariaDB
|
|
docker_network:
|
|
name: "{{ mariadb_network_name }}"
|
|
state: present
|
|
ipam_config:
|
|
- subnet: "{{ mariadb_subnet }}"
|
|
when: run_once_docker_mariadb is not defined
|
|
|
|
- name: install MariaDB
|
|
docker_container:
|
|
name: "{{ mariadb_name }}"
|
|
image: "{{ mariadb_image }}:{{ mariadb_version}}"
|
|
detach: yes
|
|
env:
|
|
MARIADB_ROOT_PASSWORD: "{{ mariadb_root_pwd }}"
|
|
MARIADB_AUTO_UPGRADE: "1"
|
|
networks:
|
|
- name: "{{ mariadb_network_name }}"
|
|
volumes:
|
|
- "{{ mariadb_volume }}:/var/lib/mysql"
|
|
published_ports:
|
|
- "127.0.0.1:{{ mariadb_port }}: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: "{{ docker_restart_policy }}"
|
|
healthcheck:
|
|
test: "/usr/bin/mariadb --user=root --password={{ mariadb_root_pwd }} --execute \"SHOW DATABASES;\""
|
|
interval: 3s
|
|
timeout: 1s
|
|
retries: 5
|
|
when: run_once_docker_mariadb is not defined
|
|
register: setup_mariadb_container_result
|
|
|
|
- name: install python-mysqlclient
|
|
pacman:
|
|
name: python-mysqlclient
|
|
state: present
|
|
when: run_once_docker_mariadb is not defined
|
|
|
|
- name: "Wait until the MariaDB container with hostname '{{ mariadb_name }}' is healthy"
|
|
community.docker.docker_container_info:
|
|
name: "{{ mariadb_name }}"
|
|
register: db_info
|
|
until:
|
|
- db_info.containers is defined
|
|
- db_info.containers | length > 0
|
|
- db_info.containers[0].State.Health.Status == "healthy"
|
|
retries: 30
|
|
delay: 5
|
|
when:
|
|
- setup_mariadb_container_result is defined
|
|
- setup_mariadb_container_result.changed
|
|
- run_once_docker_mariadb is not defined
|
|
|
|
- name: "Initialize database for '{{ database_name }}'"
|
|
include_tasks: init.yml
|
|
when: "{{ mariadb_init }}"
|
|
|
|
- name: run the docker_mariadb tasks once
|
|
set_fact:
|
|
run_once_docker_mariadb: true
|
|
when: run_once_docker_mariadb is not defined |