ansible-mysql/tasks/main.yml

69 lines
1.7 KiB
YAML
Raw Normal View History

2015-07-12 15:42:46 +07:00
---
- name: INCLUDE_VARS | Related to OS version
2021-09-01 18:31:11 +07:00
include_vars: "{{ ansible_distribution }}.yml"
2015-07-12 15:42:46 +07:00
- name: STAT | Check if mysql exists
2018-03-17 23:28:54 +07:00
stat:
path: /usr/sbin/mysqld
2018-03-17 23:28:54 +07:00
register: mariadb_exists
2015-07-12 15:42:46 +07:00
changed_when: false
2015-07-12 17:47:44 +07:00
- name: INCLUDE | Install
import_tasks: install/main.yml
2015-07-12 17:47:44 +07:00
- name: TEMPLATE | Deploy config files
2018-03-18 00:28:56 +07:00
template:
src: "{{ item }}"
dest: "/{{ item | replace('.j2', '') }}"
loop:
- etc/mysql/my.cnf
- etc/mysql/conf.d/mysqldump.cnf.j2
- etc/mysql/mariadb.conf.d/10-extra.cnf.j2
- etc/mysql/mariadb.conf.d/50-client.cnf.j2
- etc/mysql/mariadb.conf.d/50-mysqld_safe.cnf.j2
- etc/mysql/mariadb.conf.d/50-server.cnf.j2
register: config
2015-08-11 04:45:01 +07:00
- name: SERVICE | Restart Mariadb now one at a time (prevent bugs)
throttle: 1
2018-03-18 00:28:56 +07:00
service:
2021-09-01 18:31:11 +07:00
name: mariadb
2018-03-18 00:28:56 +07:00
state: restarted
when:
config.changed and
2018-03-17 23:28:54 +07:00
not mariadb_galera_resetup
2015-07-12 15:42:46 +07:00
2021-09-01 18:31:11 +07:00
- name: SERVICE | Ensure service is started
service:
name: mariadb
state: started
- name: INCLUDE | Galera
import_tasks: galera/main.yml
when: mariadb_use_galera
- name: INCLUDE | Replication
import_tasks: replication/main.yml
2018-03-17 23:28:54 +07:00
when: mariadb_replication_master or mariadb_replication_slave
2015-08-08 04:34:47 +07:00
2015-07-12 15:42:46 +07:00
- name: INCLUDE | Secure install
import_tasks: 'secure.yml'
2015-07-12 15:42:46 +07:00
- name: MYSQL_DB | Create databases
2018-03-18 00:28:56 +07:00
mysql_db:
name: "{{ item }}"
state: present
2019-04-12 14:38:42 +07:00
loop: "{{ mariadb_databases }}"
2015-07-12 15:42:46 +07:00
- name: MYSQL_USER | Manages users...
2018-03-18 00:28:56 +07:00
mysql_user:
name: "{{ item.name }}"
password: "{{ item.password }}"
priv: "{{ item.priv }}"
2019-01-25 17:42:04 +07:00
host: "{{ item.host | default(omit) }}"
host_all: "{{ item.host_all | default(omit) }}"
2018-03-18 00:28:56 +07:00
state: present
2019-04-12 14:38:42 +07:00
loop: "{{ mariadb_users }}"
no_log: "{{ not mariadb_debug_role }}"