ansible-mysql/tasks/galera/bootstrap.yml

49 lines
1.4 KiB
YAML

---
- name: SET_FACT | Prepare mark var
ansible.builtin.set_fact:
__mark: "{{ mariadb_datadir }}/.ansible_galera_boostrap"
- name: STAT | Bootstrap mark
ansible.builtin.stat:
path: "{{ __mark }}"
register: s
- block:
- name: SET_FACT | We must NOT restart after bootstrap!
ansible.builtin.set_fact:
mariadb_notify_restart: false
- name: SERVICE | Stop MariaDB
ansible.builtin.service:
name: "{{ mariadb_service_name }}"
state: stopped
- name: COMMAND | Bootstrap first node (systemd)
ansible.builtin.command: galera_new_cluster
when: ansible_service_mgr == 'systemd'
- name: SERVICE | Bootstrap first node (clean init)
ansible.builtin.service:
name: "{{ mariadb_service_name }}"
state: "started"
arguments: --wsrep-new-cluster
register: bootstrap_run
when: ansible_service_mgr != 'systemd'
- 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 != ''
when: not s.stat.exists or mariadb_galera_resetup
- name: COMMAND | Create Bootstrap mark
ansible.builtin.command: "touch {{ __mark }}"
args:
creates: "{{ __mark }}"