community.proxysql.proxysql_mysql_hostgroup_attributes module – Manages hostgroup attributes using the ProxySQL admin interface
Note
This module is part of the community.proxysql collection (version 1.7.0).
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_mysql_hostgroup_attributes.
New in community.proxysql 1.7.0
Synopsis
Each row in mysql_hostgroup_attributes provides a per-hostgroup override of a specific hostgroup. This extension table allows for hostgroup-specific configurations, like `max_num_online_servers`, which change the behaviour of the given hostgroup in ways that are not otherwise possible.
Requirements
The below requirements are needed on the host that executes this module.
PyMySQL
mysqlclient
Parameters
Parameter |
Comments |
|---|---|
Not yet implemented (as per ProxySQL documentation). Default: |
|
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: |
|
Whether ProxySQL will opening new connections until the expected number of warm connections is reached Default: |
|
The percentage of open idle connections for each server in a hostgroup. Default: |
|
ID of the hostgroup |
|
Override certain global configurations. Default: |
|
Not yet implemented (as per ProxySQL documentation). Default: |
|
Semicolon-delimited string of SQL statements to be executed for each back-end connection when initialized. 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. |
|
Prevents new connections when the number of ONLINE servers in the hostgroup exceeds this number. Default: |
|
Enables or disables multiplexing for the specific hostgroup Default: |
|
Save config to sqlite db on disk to persist the configuration. Choices:
|
|
Provide default values for discovered servers. Default: |
|
When Choices:
|
|
Maximum number of new connections that can be opened per second. Default: |
Attributes
Attribute |
Support |
Description |
|---|---|---|
Support: full |
Do not make any changes to memory, disk, or runtime. |
Examples
# This example uses supplied credentials to add a hostgroup override for the
# hostgroup with ID, `1`. The override sets the maximum number of ONLINE
# servers to `1` and provides a short comment. The configuration will be saved
# to disk and memory, but not loaded into runtime.
- name: Add hostgroup overrides to limit servers
community.proxysql.proxysql_mysql_hostgroup_overrides:
login_user: admin
login_password: admin
hostgroup_id: 1
state: present
load_to_runtime: false
max_num_online_servers: 1
comment: >-
Limit connections to the writer hostgroup to prevent split-brains.
# This example uses stored configuration to manage a hostgroup override for the
# hostgroup with ID, `2`. The override limits the number of new connections
# that can be opened to 100/sec. The configuration will be saved to memory and
# runtime but not persisted to disk.
- name: Throttle connections on reader hostgroup
community.proxysql.proxysql_mysql_hostgroup_overrides:
config_file: /etc/proxysql/admin.cnf
hostgroup_id: 2
state: present
load_to_runtime: true
save_to_disk: false
throttle_connections_per_sec: 100
# This example uses supplied credentials to add a hostgroup override for the
# hostgroup with ID, `2`. The override enables multiplexing and sets the number
# of cached connections to 100%. The configuration will be saved to memory but
# not disk or runtime.
- name: Aggressively reuse and cache connections
community.proxysql.proxysql_mysql_hostgroup_overrides:
login_user: admin
login_password: admin
hostgroup_id: 2
load_to_runtime: false
save_to_disk: false
multiplex: 1
free_connections_pct: 100
# This example uses stored configuration to manage a hostgroup override for the
# hostgroup with ID, `42`. The override changes the hostgroup to handle
# warnings and each server added into the hostgroup to have 1000 connections.
- name: Override globals for hostgroup 42
community.proxysql.proxysql_mysql_hostgroup_overrides:
config_file: /etc/proxysql/admin.cnf
hostgroup_id: 42
hostgroup_settings: >-
{
"handle_warnings": 1
}
server_settings: >-
{
"max_connections": 1000
}
# This example removes a hostgroup override using the credentials supplied in
# a configuration file.
- name: Remove hostgroup overrides
community.proxysql.proxysql_mysql_hostgroup_attributes:
config_file: '~/proxysql.cnf'
hostgroup_id: 3
state: absent
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
|---|---|
The mysql_hostgroup_override modified or removed from ProxySQL. Returned: On create/update will return the newly modified group, on delete it will return the deleted record. Sample: |