Use proxysql_mysql_users
module in ansible-playbook
as such;
- name: create ProxySQL user
proxysql_mysql_users:
login_user: "admin"
login_password: "adminpassword"
username: "usernamestring"
password: "passwordstring"
state: present
load_to_runtime: true
save_to_disk: true
Causes error below:
...snip...
in check_user_privs\r\nTypeError: tuple indices must be integers or slices, not str\r\n",
...snip...
- Ansible 2.9.1 to 2.9.3
- ProxySQL 2.0.8
- Python 3.6.8 on target server
For example def check_user_privs(self, cursor)
in AnsiballZ_proxysql_mysql_users.py
cursor.execute(query_string, query_data)
check_count = cursor.fetchone()
return (int(check_count['user_count']) > 0)
cursor
has been dict type so far, but currently it is returned in tuple type.
For this reason, an error occurs at check_count['user_count']
.
Change proxysql_mysql_users.py
temporarily:
cursor = None
try:
cursor = mysql_connect(module,
login_user,
login_password,
config_file,
cursor_class=mysql_driver.cursors.DictCursor) <---*** HERE ***
to
cursor = None
try:
cursor = mysql_connect(module,
login_user,
login_password,
config_file,
cursor_class='DictCursor') <---*** CHANGE LIKE THIS ***
In macOS (homebrew), edit this file:
/usr/local/Cellar/ansible/2.9.1/libexec/lib/python3.7/site-packages/ansible/modules/database/proxysql/proxysql_mysql_users.py
or
/usr/local/Cellar/ansible/2.9.3/libexec/lib/python3.8/site-packages/ansible/modules/database/proxysql/proxysql_mysql_users.py
or
/usr/local/Cellar/ansible/2.9.4/libexec/lib/python3.8/site-packages/ansible/modules/database/proxysql/proxysql_mysql_users.py
or
/usr/local/Cellar/ansible/2.9.4_1/libexec/lib/python3.8/site-packages/ansible/modules/database/proxysql/proxysql_mysql_users.py
Fixed at
/usr/local/Cellar/ansible/2.9.6_1/libexec/lib/python3.8/site-packages/ansible/modules/database/proxysql/proxysql_mysql_users.py