ansible-mysql/tasks/galera/nodes.yml

56 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
- name: COMMAND | GET debian.cnf from primary node
ansible.builtin.command: cat /etc/mysql/debian.cnf
register: debiancnf
delegate_to: '{{ mariadb_galera_primary_node }}'
changed_when: false
- name: COMMAND | Get current debian.cnf
ansible.builtin.command: cat /etc/mysql/debian.cnf
register: ondc
changed_when: false
- block:
- name: SERVICE | Stop MariaDB
ansible.builtin.service:
name: "{{ mariadb_service_name }}"
state: stopped
- name: COPY | Paste primary node's debian.cnf
ansible.builtin.copy:
content: "{{ debiancnf.stdout }}"
dest: /etc/mysql/debian.cnf
mode: 0600
owner: root
group: root
register: paste
- name: SERVICE | Start MariaDB
ansible.builtin.service:
name: "{{ mariadb_service_name }}"
state: started
when: debiancnf.stdout != ondc.stdout
- name: SERVICE | Restart MariaDB if needed
ansible.builtin.service:
name: "{{ mariadb_service_name }}"
state: restarted
throttle: 1
when: not s.stat.exists or mariadb_galera_resetup
- name: COMMAND | Create Bootstrap mark
ansible.builtin.command: "touch {{ __mark }}"
args:
creates: "{{ __mark }}"