community.proxysql.proxysql_mysql_users module – Adds or removes mysql users from proxysql admin interface
Note
This module is part of the community.proxysql collection (version 1.4.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
.
To use it in a playbook, specify: community.proxysql.proxysql_mysql_users
.
Synopsis
The community.proxysql.proxysql_mysql_users module adds or removes mysql users using the proxysql admin interface.
Requirements
The below requirements are needed on the host that executes this module.
PyMySQL
mysqlclient
Parameters
Parameter |
Comments |
---|---|
A user with active set to Choices:
|
|
If backend is set to Choices:
|
|
Specify a config file from which login_user and login_password are to be read. Default: “” |
|
If there is no matching rule for the queries sent by this user, the traffic it generates is sent to the specified hostgroup. If omitted the proxysql database default for use_ssl is 0. |
|
The schema to which the connection should change to by default. |
|
Encrypt a cleartext password passed in the password option, using the method defined in encryption_method. Choices:
|
|
Encryption method used when encrypt_password is set to Choices:
|
|
If fast_forward is set to Choices:
|
|
If frontend is set to Choices:
|
|
Dynamically load config to runtime memory. Choices:
|
|
The host used to connect to ProxySQL admin interface. Default: “127.0.0.1” |
|
The password used to authenticate to ProxySQL admin interface. |
|
The port used to connect to ProxySQL admin interface. Default: 6032 |
|
The socket used to connect to ProxySQL admin interface. |
|
The username used to authenticate to ProxySQL admin interface. |
|
The maximum number of connections ProxySQL will open to the backend for this user. If omitted the proxysql database default for max_connections is 10000. |
|
Password of the user connecting to the mysqld or ProxySQL instance. |
|
Save config to sqlite db on disk to persist the configuration. Choices:
|
|
When Choices:
|
|
If this is set for the user with which the MySQL client is connecting to ProxySQL (thus a “frontend” user), transactions started within a hostgroup will remain within that hostgroup regardless of any other rules. If omitted the proxysql database default for transaction_persistent is Choices:
|
|
If use_ssl is set to Choices:
|
|
Name of the user connecting to the mysqld or ProxySQL instance. |
Examples
---
# This example adds a user, it saves the mysql user config to disk, but
# avoids loading the mysql user config to runtime (this might be because
# several users 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 user
community.proxysql.proxysql_mysql_users:
login_user: 'admin'
login_password: 'admin'
username: 'productiondba'
state: present
load_to_runtime: False
# This example removes a user, saves the mysql user config to disk, and
# dynamically loads the mysql user config to runtime. It uses credentials
# in a supplied config file to connect to the proxysql admin interface.
- name: Remove a user
community.proxysql.proxysql_mysql_users:
config_file: '~/proxysql.cnf'
username: 'mysqlboy'
state: absent
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
The mysql user modified or removed from proxysql. Returned: On create/update will return the newly modified user, on delete it will return the deleted record. Sample: {“changed”: true, “msg”: “Added user to mysql_users”, “state”: “present”, “user”: {“active”: 1, “backend”: 1, “default_hostgroup”: 1, “default_schema”: null, “fast_forward”: 0, “frontend”: 1, “max_connections”: 10000, “password”: “VALUE_SPECIFIED_IN_NO_LOG_PARAMETER”, “schema_locked”: 0, “transaction_persistent”: 0, “use_ssl”: 0, “username”: “guest_ro”}, “username”: “guest_ro”} |
Authors
Ben Mildren (@bmildren)