community / community.proxysql / 1.5.1 / module / proxysql_replication_hostgroups Manages replication hostgroups using the proxysql admin interface Authors: Ben Mildren (@bmildren)community.proxysql.proxysql_replication_hostgroups (1.5.1) — module
Install with ansible-galaxy collection install community.proxysql:==1.5.1
collections: - name: community.proxysql version: 1.5.1
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.
--- # 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
state: choices: - present - absent default: present description: - When C(present) - adds the replication hostgroup, when C(absent) - removes the replication hostgroup. type: str comment: default: '' description: - Text field that can be used for any purposes defined by the user. type: str check_type: choices: - read_only - innodb_read_only - super_read_only - read_only|innodb_read_only - read_only&innodb_read_only default: read_only description: - Which check type to use when detecting that the node is a standby. - Requires proxysql >= 2.0.1. Otherwise it has no effect. - C(read_only|innodb_read_only) and C(read_only&innodb_read_only) requires proxysql >= 2.0.8. type: str version_added: 1.3.0 version_added_collection: community.proxysql login_host: default: 127.0.0.1 description: - The host used to connect to ProxySQL admin interface. type: str login_port: default: 6032 description: - The port used to connect to ProxySQL admin interface. type: int login_user: description: - The username used to authenticate to ProxySQL admin interface. type: str config_file: default: '' description: - Specify a config file from which I(login_user) and I(login_password) are to be read. type: path save_to_disk: default: true description: - Save config to sqlite db on disk to persist the configuration. type: bool login_password: description: - The password used to authenticate to ProxySQL admin interface. type: str load_to_runtime: default: true description: - Dynamically load config to runtime memory. type: bool reader_hostgroup: description: - Id of the reader hostgroup. required: true type: int writer_hostgroup: description: - Id of the writer hostgroup. required: true type: int login_unix_socket: description: - The socket used to connect to ProxySQL admin interface. type: str
stdout: 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: changed: true msg: Added server to mysql_hosts repl_group: check_type: read_only comment: '' reader_hostgroup: '1' writer_hostgroup: '2' state: present type: dict