2022-08-12 01:04:07 +00:00
|
|
|
- name: Install MariaDB
|
2023-05-04 03:42:55 +00:00
|
|
|
ansible.builtin.apt:
|
2022-08-12 01:04:07 +00:00
|
|
|
name: mariadb-server
|
|
|
|
state: present
|
|
|
|
|
2023-10-22 15:33:05 +00:00
|
|
|
- name: Set MariaDB restarted fact
|
2023-11-06 02:34:19 +00:00
|
|
|
ansible.builtin.set_fact:
|
2023-10-22 15:33:05 +00:00
|
|
|
mariadb_restarted: false
|
|
|
|
|
2023-10-20 19:41:44 +00:00
|
|
|
- name: Regather facts for the potentially new docker0 interface
|
|
|
|
ansible.builtin.setup:
|
|
|
|
|
|
|
|
- name: Change the bind-address to allow from docker0
|
2023-05-04 03:42:55 +00:00
|
|
|
ansible.builtin.lineinfile:
|
2022-08-12 01:04:07 +00:00
|
|
|
path: /etc/mysql/mariadb.conf.d/50-server.cnf
|
|
|
|
regex: "^bind-address"
|
2023-10-20 19:41:44 +00:00
|
|
|
line: "bind-address = {{ ansible_facts.docker0.ipv4.address }}"
|
|
|
|
notify: restart_mariadb
|
2022-08-12 01:04:07 +00:00
|
|
|
|
2024-04-22 02:27:48 +00:00
|
|
|
- name: Flush handlers to ensure MariaDB restarts immediately
|
|
|
|
ansible.builtin.meta: flush_handlers
|
|
|
|
tags: restart_mariadb
|
|
|
|
|
2023-10-20 19:41:44 +00:00
|
|
|
- name: Allow database connections from Docker
|
2023-05-04 03:42:55 +00:00
|
|
|
community.general.ufw:
|
2022-08-12 01:04:07 +00:00
|
|
|
rule: allow
|
|
|
|
port: "3306"
|
|
|
|
proto: tcp
|
|
|
|
src: "{{ item }}"
|
2023-10-20 19:41:44 +00:00
|
|
|
loop: "{{ mariadb_trust | default(['172.16.0.0/12']) }}"
|