mirror of
https://github.com/HanXHX/ansible-mysql.git
synced 2026-02-26 10:22:09 +07:00
🚀 Manage Galera
This commit is contained in:
committed by
Emilien M
parent
cdfd71ce76
commit
c32411c6e4
@@ -2,3 +2,4 @@
|
||||
|
||||
mariadb_use_galera: true
|
||||
mariadb_galera_members: "{{ groups['galera'] }}"
|
||||
mariadb_galera_primary_node: "{{ mariadb_galera_members | first }}"
|
||||
|
||||
9
molecule/debian12_galera/converge.yml
Normal file
9
molecule/debian12_galera/converge.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
---
|
||||
|
||||
- name: Converge
|
||||
hosts: all
|
||||
gather_facts: true
|
||||
tasks:
|
||||
- name: Include role
|
||||
ansible.builtin.include_role:
|
||||
name: "hanxhx.mysql"
|
||||
55
molecule/debian12_galera/molecule.yml
Normal file
55
molecule/debian12_galera/molecule.yml
Normal file
@@ -0,0 +1,55 @@
|
||||
---
|
||||
|
||||
platforms:
|
||||
- name: debian12-galera1
|
||||
image: dokken/debian-12
|
||||
command: /lib/systemd/systemd
|
||||
dockerfile: ../_shared/Dockerfile.j2
|
||||
capabilities:
|
||||
- SYS_ADMIN
|
||||
cgroupns_mode: host
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:rw
|
||||
privileged: true
|
||||
groups:
|
||||
- galera
|
||||
networks:
|
||||
- name: "00-molecule-d12-galera"
|
||||
ipv4_address: '172.16.51.1'
|
||||
docker_networks:
|
||||
- name: "00-molecule-d12-galera"
|
||||
ipam_config:
|
||||
- subnet: "172.16.51.0/24"
|
||||
gateway: "172.16.51.254"
|
||||
|
||||
- name: debian12-galera2
|
||||
image: dokken/debian-12
|
||||
command: /lib/systemd/systemd
|
||||
dockerfile: ../_shared/Dockerfile.j2
|
||||
capabilities:
|
||||
- SYS_ADMIN
|
||||
cgroupns_mode: host
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:rw
|
||||
privileged: true
|
||||
groups:
|
||||
- galera
|
||||
networks:
|
||||
- name: "00-molecule-d12-galera"
|
||||
ipv4_address: '172.16.51.2'
|
||||
|
||||
- name: debian12-galera3
|
||||
image: dokken/debian-12
|
||||
command: /lib/systemd/systemd
|
||||
dockerfile: ../_shared/Dockerfile.j2
|
||||
capabilities:
|
||||
- SYS_ADMIN
|
||||
cgroupns_mode: host
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:rw
|
||||
privileged: true
|
||||
groups:
|
||||
- galera
|
||||
networks:
|
||||
- name: "00-molecule-d12-galera"
|
||||
ipv4_address: '172.16.51.3'
|
||||
31
molecule/debian12_galera/verify.yml
Normal file
31
molecule/debian12_galera/verify.yml
Normal file
@@ -0,0 +1,31 @@
|
||||
---
|
||||
|
||||
- name: Verify Galera
|
||||
hosts: galera
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: MYSQL_QUERY | Check if Galera is running
|
||||
community.mysql.mysql_query:
|
||||
query: "SHOW GLOBAL STATUS LIKE 'wsrep_ready'"
|
||||
login_unix_socket: /run/mysqld/mysqld.sock
|
||||
register: wsrep_ready
|
||||
|
||||
- name: ASSERT | Fail if Galera is not running
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- wsrep_ready.query_result.0.0.Value == "ON"
|
||||
fail_msg: "Galera is not running"
|
||||
success_msg: "Galera is running"
|
||||
|
||||
- name: MYSQL_QUERY | Check Galera status
|
||||
community.mysql.mysql_query:
|
||||
query: "SHOW GLOBAL STATUS LIKE 'wsrep_local_state_comment'"
|
||||
login_unix_socket: /run/mysqld/mysqld.sock
|
||||
register: wsrep_local_state_comment
|
||||
|
||||
- name: ASSERT | Fail if Galera is not on the right state
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- wsrep_local_state_comment.query_result.0.0.Value == "Synced"
|
||||
fail_msg: "Galera is not expected state ({{ wsrep_local_state_comment.query_result.0.0.Value }})"
|
||||
success_msg: "Galera is in expected state"
|
||||
Reference in New Issue
Block a user