2019-02-21 21:19:56 +00:00
|
|
|
---
|
2019-05-18 10:26:37 +00:00
|
|
|
- import_tasks: repo.yml
|
|
|
|
when: mariadb_use_official_repository|bool
|
|
|
|
|
2019-02-21 21:19:56 +00:00
|
|
|
- name: install package
|
|
|
|
package:
|
2019-02-23 19:07:16 +00:00
|
|
|
name: '{{ packages }}'
|
|
|
|
vars:
|
|
|
|
packages:
|
|
|
|
- mariadb-server
|
|
|
|
- python-mysqldb
|
2020-02-08 16:32:59 +00:00
|
|
|
- python3-mysqldb
|
2019-02-21 21:19:56 +00:00
|
|
|
retries: 2
|
|
|
|
register: result
|
|
|
|
until: result is succeeded
|
|
|
|
tags: mariadb
|
|
|
|
|
|
|
|
- name: copy configuration file
|
|
|
|
template:
|
|
|
|
src: my.cnf.j2
|
2019-05-18 10:26:37 +00:00
|
|
|
dest: /etc/mysql/my.cnf
|
2019-02-21 21:19:56 +00:00
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
|
|
|
notify: restart mariadb
|
|
|
|
tags: mariadb
|
|
|
|
|
2019-03-17 14:10:04 +00:00
|
|
|
- name: check if datadir exist
|
|
|
|
stat:
|
|
|
|
path: '{{ mariadb_full_config.mysqld.datadir }}'
|
|
|
|
register: st
|
|
|
|
tags: mariadb
|
|
|
|
|
|
|
|
- import_tasks: initdb.yml
|
|
|
|
when: not st.stat.exists
|
|
|
|
|
2019-02-21 21:19:56 +00:00
|
|
|
- name: enable and start the service
|
|
|
|
service:
|
|
|
|
name: mysql
|
|
|
|
state: started
|
|
|
|
enabled: yes
|
|
|
|
tags: mariadb
|
|
|
|
|
|
|
|
- name: manage users
|
|
|
|
mysql_user:
|
|
|
|
name: '{{ item.name }}'
|
|
|
|
host: '{{ item.host }}'
|
|
|
|
password: '{{ item.password }}'
|
2021-08-22 13:57:52 +00:00
|
|
|
priv: '{{ item.privileges|default("")|join("/") }}'
|
2019-02-21 21:19:56 +00:00
|
|
|
state: '{{ item.state|default("present") }}'
|
|
|
|
login_user: '{{ mariadb_user }}'
|
|
|
|
login_password: '{{ mariadb_password }}'
|
|
|
|
loop: '{{ mariadb_users }}'
|
|
|
|
run_once: true
|
|
|
|
no_log: true
|
2019-06-03 18:23:58 +00:00
|
|
|
when: mariadb_master|bool
|
2019-02-21 21:19:56 +00:00
|
|
|
tags: mariadb
|
|
|
|
|
|
|
|
- name: manage databases
|
|
|
|
mysql_db:
|
|
|
|
name: '{{ item.name }}'
|
|
|
|
state: '{{ item.state|default("present") }}'
|
|
|
|
login_user: '{{ mariadb_user }}'
|
|
|
|
login_password: '{{ mariadb_password }}'
|
|
|
|
loop: '{{ mariadb_databases }}'
|
|
|
|
run_once: true
|
|
|
|
no_log: true
|
2019-06-03 18:23:58 +00:00
|
|
|
when: mariadb_master|bool
|
2019-02-21 21:19:56 +00:00
|
|
|
tags: mariadb
|