Ansible Role proxysql
This role installs and configures ProxySQL. Note that running this role always reloads the config from /etc/proxysql.cnf
into ProxySQL’s internal database.
Mandatory Role Variables
Variable |
Description |
---|---|
|
The ProxySQL account for administrating ProxySQL. |
|
The MariaDB account for monitoring the backend SQL nodes. The user has to exist in MariaDB and have |
Example:
# mandatory
proxysql__admin_users:
- username: 'proxysql-admin'
password: 'linuxfabrik'
proxysql__monitor_user:
username: 'proxysql-monitor'
password: 'linuxfabrik'
Optional Role Variables
Variable |
Description |
Default Value |
---|---|---|
|
Account used internally for communication in ProxySQL clusters. |
unset |
|
List of dictionaries defining the hostgroups for the use with Galera. Subkeys:
|
|
|
List of dictionaries determining the routing of queries to the backends. Subkeys:
|
|
|
List of dictionaries defining the hostgroups for the use with MariaDB/MySQL replication. Subkeys:
|
|
|
List of dictionaries defining the backend MariaDB/MySQL servers. Subkeys:
|
|
|
List of dictionaries defining the MariaDB/MySQL users. They have to already exist in the DB. Subkeys:
|
|
|
List of dictionaries defining the ProxySQL inside a cluster. Subkeys:
|
|
|
Enables or disables the ProxySQL service, analogous to |
|
Example:
# optional
proxysql__cluster_user:
username: 'proxysql-monitor'
password: 'linuxfabrik'
proxysql__mysql_galera_hostgroups__host_var:
- writer_hostgroup: 0
backup_writer_hostgroup: 3
reader_hostgroup: 1
offline_hostgroup: 4
max_writers: 1
writer_is_also_reader: 1
max_transactions_behind: 30
proxysql__mysql_query_rules__host_var:
# read/write split
- rule_id: 100
active: true
match_pattern: '^SELECT .* FOR UPDATE'
destination_hostgroup: 0 # writer_hostgroup
apply: 1
- rule_id: 200
active: true
match_pattern: '^SELECT .*'
destination_hostgroup: 1 # reader_hostgroup
apply: 1
- rule_id: 300
active: true
match_pattern: '.*'
destination_hostgroup: 0 # writer_hostgroup
apply: 1
proxysql__mysql_replication_hostgroups__host_var:
writer_hostgroup: 0
reader_hostgroup: 1
proxysql__mysql_servers__host_var:
- address: 'mariadb01.example.com'
port: 3306
use_ssl: true
hostgroup: 10
weight: 100
max_replication_lag: 30
proxysql__mysql_users__host_var:
- username: 'user1'
password: 'linuxfabrik'
use_ssl: true
default_hostgroup: 0
state: 'present'
proxysql__proxysql_servers__group_var:
- hostname: 'proxysql1.example.com'
port: 6032
- hostname: 'proxysql2.example.com'
port: 6032
proxysql__service_enabled: true