feat: added mariadb role
This commit is contained in:
parent
83c6ce3513
commit
d1c59d65de
13 changed files with 170 additions and 1 deletions
|
@ -0,0 +1,36 @@
|
|||
---
|
||||
- name: install server packages
|
||||
become: true
|
||||
ansible.builtin.apt:
|
||||
update_cache: true
|
||||
cache_valid_time: 3600
|
||||
force_apt_get: true
|
||||
pkg:
|
||||
- mariadb-common
|
||||
- mariadb-server
|
||||
- mariadb-server-core
|
||||
|
||||
- name: initialize database
|
||||
become: true
|
||||
block:
|
||||
- name: export initialization SQL file
|
||||
ansible.builtin.template:
|
||||
src: ../templates/mariadb_init.sql.j2
|
||||
dest: /tmp/mariadb_init.sql
|
||||
mode: '0600'
|
||||
register: sql_init
|
||||
- name: run initialization file
|
||||
ansible.builtin.shell: mysql < /tmp/mariadb_init.sql
|
||||
when: sql_init.changed
|
||||
when: mariadb_server_run_init_sql is truthy or mariadb_server_run_custom_sql is truthy
|
||||
|
||||
- name: update bind addresses to allow external connections
|
||||
become: true
|
||||
ansible.builtin.lineinfile:
|
||||
path: /etc/mysql/mariadb.conf.d/50-server.cnf
|
||||
regexp: '^bind-address\b.+'
|
||||
line: "bind-address = {{ mariadb_server_bind_addresses|join(',') }}"
|
||||
state: present
|
||||
when: mariadb_server_bind_addresses is truthy
|
||||
notify:
|
||||
- 'mariadb : restart mariadb service'
|
Loading…
Add table
Add a link
Reference in a new issue