2015-07-12 15:42:46 +07:00
|
|
|
---
|
|
|
|
|
2017-06-28 21:15:44 +07:00
|
|
|
- name: INCLUDE_VARS | Related to OS version
|
|
|
|
include_vars: "{{ ansible_distribution }}-{{ ansible_distribution_release }}.yml"
|
|
|
|
|
2015-07-12 15:42:46 +07:00
|
|
|
- name: STAT | Check if mysql exists
|
2018-03-17 23:28:54 +07:00
|
|
|
stat:
|
2018-03-18 01:00:21 +07:00
|
|
|
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
|
2015-08-21 14:40:44 +07:00
|
|
|
include: install/main.yml
|
2015-07-12 17:47:44 +07:00
|
|
|
|
2015-08-11 04:45:01 +07:00
|
|
|
- name: TEMPLATE | Deploy configuration
|
2018-03-18 00:28:56 +07:00
|
|
|
template:
|
|
|
|
src: "{{ mariadb_config_template }}"
|
|
|
|
dest: /etc/mysql/my.cnf
|
2015-08-11 15:22:58 +07:00
|
|
|
register: config
|
2015-08-11 04:45:01 +07:00
|
|
|
|
|
|
|
- name: TEMPLATE | Deploy extra configuration
|
2018-03-18 00:28:56 +07:00
|
|
|
template:
|
|
|
|
src: etc/mysql/conf.d/10-extra.cnf.j2
|
|
|
|
dest: /etc/mysql/conf.d/10-extra.cnf
|
2015-08-21 15:14:23 +07:00
|
|
|
register: extraconfig
|
|
|
|
|
|
|
|
- name: SERVICE | Restart now (prevent bugs)
|
2018-03-18 00:28:56 +07:00
|
|
|
service:
|
|
|
|
name: mysql
|
|
|
|
state: restarted
|
2016-09-23 16:40:35 +07:00
|
|
|
when: >
|
2016-10-03 17:16:56 +07:00
|
|
|
(config.changed or extraconfig.changed) and
|
2018-03-17 23:28:54 +07:00
|
|
|
not mariadb_galera_resetup
|
2015-07-12 15:42:46 +07:00
|
|
|
|
|
|
|
- name: TEMPLATE Create .my.cnf for root
|
2018-03-18 00:28:56 +07:00
|
|
|
template:
|
|
|
|
src: root/my.cnf
|
|
|
|
dest: /root/.my.cnf
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0600
|
|
|
|
backup: yes
|
2015-07-12 15:42:46 +07:00
|
|
|
|
2016-09-23 22:03:13 +07:00
|
|
|
- name: INCLUDE | Galera
|
|
|
|
include: galera/main.yml
|
2018-03-17 23:28:54 +07:00
|
|
|
when: mariadb_vendor == 'mariadb_galera'
|
2016-09-23 22:03:13 +07:00
|
|
|
|
2015-08-21 15:10:27 +07:00
|
|
|
- name: INCLUDE | Replication
|
|
|
|
include: 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
|
|
|
|
include: 'secure.yml'
|
|
|
|
|
2017-06-01 21:26:24 +07:00
|
|
|
- name: SERVICE | Ensure service is started
|
2018-03-18 00:28:56 +07:00
|
|
|
service:
|
|
|
|
name: mysql
|
|
|
|
state: started
|
2017-06-01 21:26:24 +07:00
|
|
|
|
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 }}"
|
2018-03-08 19:01:34 +07:00
|
|
|
|
|
|
|
- name: TEMPLATE | Deploy logrotate configuration
|
|
|
|
template:
|
|
|
|
src: "etc/logrotate.d/mysql-server.j2"
|
|
|
|
dest: "/etc/logrotate.d/mysql-server"
|
2018-03-17 23:28:54 +07:00
|
|
|
when: mariadb_manage_logrotate
|