2016-09-23 22:03:13 +07:00
|
|
|
---
|
|
|
|
|
2021-09-02 23:17:54 +07:00
|
|
|
- name: APT | Install Galera
|
|
|
|
ansible.builtin.apt:
|
|
|
|
pkg: "{{ mariadb_galera_package_name }}"
|
|
|
|
|
2016-09-23 22:03:13 +07:00
|
|
|
- name: TEMPLATE | Deploy Galera configuration
|
2021-09-02 23:17:54 +07:00
|
|
|
ansible.builtin.template:
|
2019-12-29 01:02:41 +07:00
|
|
|
src: etc/mysql/mariadb.conf.d/20-galera.cnf.j2
|
|
|
|
dest: /etc/mysql/mariadb.conf.d/20-galera.cnf
|
2021-09-02 23:17:54 +07:00
|
|
|
mode: 0644
|
|
|
|
owner: root
|
|
|
|
group: root
|
2016-09-23 22:03:13 +07:00
|
|
|
register: galeraconfig
|
|
|
|
|
|
|
|
- name: INCLUDE | Bootstrap first node
|
2021-09-02 23:17:54 +07:00
|
|
|
ansible.builtin.import_tasks: 'bootstrap.yml'
|
2018-03-17 23:28:54 +07:00
|
|
|
when: inventory_hostname == mariadb_galera_primary_node
|
2016-09-23 22:03:13 +07:00
|
|
|
|
|
|
|
- name: INCLUDE | Configure other nodes
|
2021-09-02 23:17:54 +07:00
|
|
|
ansible.builtin.import_tasks: 'nodes.yml'
|
2018-03-17 23:28:54 +07:00
|
|
|
when: inventory_hostname != mariadb_galera_primary_node
|
2016-09-23 22:03:13 +07:00
|
|
|
|
|
|
|
- name: SERVICE | Restart MariaDB if needed
|
2021-09-02 23:17:54 +07:00
|
|
|
ansible.builtin.service:
|
|
|
|
name: "{{ mariadb_service_name }}"
|
2018-03-18 00:28:56 +07:00
|
|
|
state: restarted
|
2019-04-16 18:55:38 +07:00
|
|
|
when:
|
2016-10-03 17:30:26 +07:00
|
|
|
((galeraconfig or (p is defined and p.changed)) and
|
|
|
|
(bootstrap_run is not defined)) or
|
2018-03-17 23:28:54 +07:00
|
|
|
((inventory_hostname != mariadb_galera_primary_node) and
|
|
|
|
(mariadb_galera_resetup))
|