2016-09-23 22:03:13 +07:00
|
|
|
---
|
2022-05-07 04:44:28 +07:00
|
|
|
- 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
|
2016-09-23 22:03:13 +07:00
|
|
|
|
|
|
|
- name: COMMAND | GET debian.cnf from primary node
|
2021-09-02 23:17:54 +07:00
|
|
|
ansible.builtin.command: cat /etc/mysql/debian.cnf
|
2016-09-23 22:03:13 +07:00
|
|
|
register: debiancnf
|
2018-03-17 23:28:54 +07:00
|
|
|
delegate_to: '{{ mariadb_galera_primary_node }}'
|
2016-09-27 22:37:43 +07:00
|
|
|
changed_when: false
|
2016-09-23 22:03:13 +07:00
|
|
|
|
|
|
|
- name: COMMAND | Get current debian.cnf
|
2021-09-02 23:17:54 +07:00
|
|
|
ansible.builtin.command: cat /etc/mysql/debian.cnf
|
2016-09-23 22:03:13 +07:00
|
|
|
register: ondc
|
2016-09-27 22:37:43 +07:00
|
|
|
changed_when: false
|
2016-09-23 22:03:13 +07:00
|
|
|
|
|
|
|
- block:
|
|
|
|
|
|
|
|
- name: SERVICE | Stop MariaDB
|
2021-09-02 23:17:54 +07:00
|
|
|
ansible.builtin.service:
|
|
|
|
name: "{{ mariadb_service_name }}"
|
2018-03-18 00:28:56 +07:00
|
|
|
state: stopped
|
2016-09-23 22:03:13 +07:00
|
|
|
|
|
|
|
- name: COPY | Paste primary node's debian.cnf
|
2021-09-02 23:17:54 +07:00
|
|
|
ansible.builtin.copy:
|
2018-03-18 00:28:56 +07:00
|
|
|
content: "{{ debiancnf.stdout }}"
|
|
|
|
dest: /etc/mysql/debian.cnf
|
|
|
|
mode: 0600
|
|
|
|
owner: root
|
|
|
|
group: root
|
2016-09-23 22:03:13 +07:00
|
|
|
register: paste
|
|
|
|
|
|
|
|
- name: SERVICE | Start MariaDB
|
2021-09-02 23:17:54 +07:00
|
|
|
ansible.builtin.service:
|
|
|
|
name: "{{ mariadb_service_name }}"
|
2018-03-18 00:28:56 +07:00
|
|
|
state: started
|
2016-09-23 22:03:13 +07:00
|
|
|
|
|
|
|
when: debiancnf.stdout != ondc.stdout
|
2022-05-07 03:49:45 +07:00
|
|
|
|
|
|
|
- name: SERVICE | Restart MariaDB if needed
|
|
|
|
ansible.builtin.service:
|
|
|
|
name: "{{ mariadb_service_name }}"
|
|
|
|
state: restarted
|
2022-05-07 04:44:28 +07:00
|
|
|
throttle: 1
|
|
|
|
when: not s.stat.exists or mariadb_galera_resetup
|
|
|
|
|
|
|
|
- name: COMMAND | Create Bootstrap mark
|
|
|
|
ansible.builtin.command: "touch {{ __mark }}"
|
|
|
|
args:
|
|
|
|
creates: "{{ __mark }}"
|