homelab/roles/mariadb/tasks/main.yml

31 lines
870 B
YAML
Raw Normal View History

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
- name: Set MariaDB restarted fact
2023-11-06 02:34:19 +00:00
ansible.builtin.set_fact:
mariadb_restarted: false
- 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"
line: "bind-address = {{ ansible_facts.docker0.ipv4.address }}"
notify: restart_mariadb
2022-08-12 01:04:07 +00:00
- name: Flush handlers to ensure MariaDB restarts immediately
ansible.builtin.meta: flush_handlers
tags: restart_mariadb
- 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 }}"
loop: "{{ mariadb_trust | default(['172.16.0.0/12']) }}"