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
|
|
|
|
|
2024-08-26 15:12:09 +07:00
|
|
|
- name: COMMAND | Setup galera cluster
|
|
|
|
when: not s.stat.exists or mariadb_galera_resetup
|
|
|
|
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'
|
2024-08-26 15:12:09 +07:00
|
|
|
changed_when: true
|
2016-09-25 20:18:02 +07:00
|
|
|
|
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
|
|
|
|
|
|
|
- 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 }}"
|