community.proxysql.proxysql_replication_hostgroups module – Manages replication hostgroups using the proxysql admin interface
Note
This module is part of the community.proxysql collection (version 1.5.1).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install community.proxysql
.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: community.proxysql.proxysql_replication_hostgroups
.
Synopsis
Each row in mysql_replication_hostgroups represent a pair of writer_hostgroup and reader_hostgroup. ProxySQL will monitor the value of read_only for all the servers in specified hostgroups, and based on the value of read_only will assign the server to the writer or reader hostgroups.
Requirements
The below requirements are needed on the host that executes this module.
PyMySQL
mysqlclient
Parameters
Parameter |
Comments |
---|---|
Which check type to use when detecting that the node is a standby. Requires proxysql >= 2.0.1. Otherwise it has no effect.
Choices:
|
|
Text field that can be used for any purposes defined by the user. Default: |
|
Specify a config file from which login_user and login_password are to be read. Default: |
|
Dynamically load config to runtime memory. Choices:
|
|
The host used to connect to ProxySQL admin interface. Default: |
|
The password used to authenticate to ProxySQL admin interface. |
|
The port used to connect to ProxySQL admin interface. Default: |
|
The socket used to connect to ProxySQL admin interface. |
|
The username used to authenticate to ProxySQL admin interface. |
|
Id of the reader hostgroup. |
|
Save config to sqlite db on disk to persist the configuration. Choices:
|
|
When Choices:
|
|
Id of the writer hostgroup. |
Notes
Note
Supports
check_mode
.
Examples
---
# This example adds a replication hostgroup, it saves the mysql server config
# to disk, but avoids loading the mysql server config to runtime (this might be
# because several replication hostgroup are being added and the user wants to
# push the config to runtime in a single batch using the
# community.general.proxysql_manage_config module). It uses supplied credentials
# to connect to the proxysql admin interface.
- name: Add a replication hostgroup
community.proxysql.proxysql_replication_hostgroups:
login_user: 'admin'
login_password: 'admin'
writer_hostgroup: 1
reader_hostgroup: 2
state: present
load_to_runtime: false
- name: Change check_type
community.proxysql.proxysql_replication_hostgroups:
login_user: 'admin'
login_password: 'admin'
writer_hostgroup: 1
reader_hostgroup: 2
check_type: innodb_read_only
state: present
load_to_runtime: false
# This example removes a replication hostgroup, saves the mysql server config
# to disk, and dynamically loads the mysql server config to runtime. It uses
# credentials in a supplied config file to connect to the proxysql admin
# interface.
- name: Remove a replication hostgroup
community.proxysql.proxysql_replication_hostgroups:
config_file: '~/proxysql.cnf'
writer_hostgroup: 3
reader_hostgroup: 4
state: absent
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
The replication hostgroup modified or removed from proxysql. Returned: On create/update will return the newly modified group, on delete it will return the deleted record. Sample: |