Ansible playbook that provisions a group of servers to run mariadb as a Galera Cluster.
Find a file
2024-08-01 14:43:13 -06:00
collections Adding SSL Support 2024-08-01 14:43:13 -06:00
roles/mariadb_cluster Adding SSL Support 2024-08-01 14:43:13 -06:00
.gitignore Initial commit 2023-01-19 13:45:41 -07:00
hosts.yml Initial commit 2023-02-03 10:59:47 -07:00
LICENSE Initial commit 2023-01-19 13:45:41 -07:00
mariadb_cluster.yml Initial commit 2023-02-03 10:59:47 -07:00
README.md Adding SSL Support 2024-08-01 14:43:13 -06:00
site.yml Initial commit 2023-02-03 10:59:47 -07:00

Ansible-MariaDB-Cluster

Ansible playbook that provisions a group of servers to run mariadb as a Galera Cluster.

Requirements

If you are using HaProxy as a front end to the cluster without SSL, you will need to create a user for the health checks to work properly. The user does not need to be able to access any databases, it just needs to be able to authenticate against the server.

CREATE USER 'haproxy_check'@'10.10.10.253' WITH MAX_QUERIES_PER_HOUR 1 MAX_UPDATES_PER_HOUR 0 MAX_STATEMENT_TIME 0.0000000001;

If you are using HaProxy as a front end to the cluster with SSL, use default tcp checks to validate the service is available as HaProxy does not support the SSL settings for mysql.

If this is the first install, the mariadb_cluster_bootstrap variable will need to be set to true to bootstrap the cluster.

Variables

Variable Required Default Description
mariadb_cluster_wsrep_cluster_name yes my_wsrep_cluster The wsrep cluster name that should be used for the galera cluster
mariadb_cluster_access_ip no "" If defined, the normal database port (3306) will only be accessible from the defined IP for use with a load balancer

Example

---
# file: hosts

mariadb_cluster:
  hosts:
    db01:
      ansible_host: 10.10.10.11
    db02:
      ansible_host: 10.10.10.12

  vars:
    mariadb_cluster_wsrep_cluster_name: "CustomCluster1"
    mariadb_cluster_access_ip: "10.10.10.253"
    ansible_user: ansible
    

Troubleshooting

You can view the status of the cluster by running the following command.

SHOW GLOBAL STATUS LIKE 'wsrep_%';
SHOW GLOBAL VARIABLES LIKE 'have_ssl';
SHOW SESSION STATUS LIKE 'Ssl_cipher';
SHOW GLOBAL VARIABLES LIKE 'require_secure_transport';

License

See LICENSE file for full license information.