2016-09-23 22:03:13 +07:00
|
|
|
---
|
2019-04-16 18:55:38 +07:00
|
|
|
- name: SET_FACT | Prepare mark var
|
2021-09-02 23:17:54 +07:00
|
|
|
ansible.builtin.set_fact:
|
2019-04-16 18:55:38 +07:00
|
|
|
__mark: "{{ mariadb_datadir }}/.ansible_galera_boostrap"
|
2016-09-23 22:03:13 +07:00
|
|
|
|
|
|
|
- name: STAT | Bootstrap mark
|
2021-09-02 23:17:54 +07:00
|
|
|
ansible.builtin.stat:
|
2019-04-16 18:55:38 +07:00
|
|
|
path: "{{ __mark }}"
|
2016-09-23 22:03:13 +07:00
|
|
|
register: s
|
|
|
|
|
|
|
|
- block:
|
2016-09-25 20:29:51 +07:00
|
|
|
- name: SET_FACT | We must NOT restart after bootstrap!
|
2021-09-02 23:17:54 +07:00
|
|
|
ansible.builtin.set_fact:
|
2018-03-17 23:28:54 +07:00
|
|
|
mariadb_notify_restart: false
|
2016-09-23 22:03:13 +07:00
|
|
|
|
2016-09-25 20:18:02 +07:00
|
|
|
- name: SERVICE | Stop MariaDB
|
2021-09-02 23:17:54 +07:00
|
|
|
ansible.builtin.service:
|
|
|
|
name: "{{ mariadb_service_name }}"
|
2019-04-16 18:55:38 +07:00
|
|
|
state: stopped
|
2016-09-23 22:03:13 +07:00
|
|
|
|
2016-09-25 20:18:02 +07:00
|
|
|
- name: COMMAND | Bootstrap first node (systemd)
|
2021-09-02 23:17:54 +07:00
|
|
|
ansible.builtin.command: galera_new_cluster
|
2016-09-25 20:18:02 +07:00
|
|
|
when: ansible_service_mgr == 'systemd'
|
|
|
|
|
2017-06-28 22:44:17 +07:00
|
|
|
- name: SERVICE | Bootstrap first node (clean init)
|
2021-09-02 23:17:54 +07:00
|
|
|
ansible.builtin.service:
|
|
|
|
name: "{{ mariadb_service_name }}"
|
|
|
|
state: "started"
|
2017-06-28 22:44:17 +07:00
|
|
|
arguments: --wsrep-new-cluster
|
2016-09-23 22:03:13 +07:00
|
|
|
register: bootstrap_run
|
2016-09-25 20:18:02 +07:00
|
|
|
when: ansible_service_mgr != 'systemd'
|
2016-09-23 22:03:13 +07:00
|
|
|
|
2022-05-07 03:49:45 +07:00
|
|
|
- name: MYSQL_USER | Manage SST user...
|
|
|
|
community.mysql.mysql_user:
|
|
|
|
name: "{{ mariadb_galera_sst_user }}"
|
|
|
|
password: "{{ mariadb_galera_sst_password }}"
|
|
|
|
priv: "*.*:RELOAD,LOCK TABLES,REPLICATION CLIENT,PROCESS"
|
|
|
|
host: localhost
|
|
|
|
state: present
|
|
|
|
no_log: "{{ not mariadb_debug_role }}"
|
|
|
|
when: mariadb_galera_sst_user != ''
|
|
|
|
|
2018-03-17 23:28:54 +07:00
|
|
|
when: not s.stat.exists or mariadb_galera_resetup
|
2016-09-23 22:03:13 +07:00
|
|
|
|
|
|
|
- name: COMMAND | Create Bootstrap mark
|
2021-09-02 23:17:54 +07:00
|
|
|
ansible.builtin.command: "touch {{ __mark }}"
|
2016-09-23 22:03:13 +07:00
|
|
|
args:
|
2019-04-16 18:55:38 +07:00
|
|
|
creates: "{{ __mark }}"
|