ansible-collections/community.mysql

Create new account with update_password and on_new_username returns IndexError

Closed this issue · 0 comments

SUMMARY

@betanummeric reported in #629 that #580 (v3.8.0) broke a functionality of the mysql_user plugin. Adding the host in the query made by the get_existing_authentication method to search for existing users made it impossible to search all accounts with the same username.

The issue was hidden because the integration tests for the functionality were never included in the main.yml file.

While fixing this, we must keep in mind that in addition to mysql_user, there is also mysql_info that now uses the get_existing_authentication method.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

mysql_user

COLLECTION VERSION
3.8.0 to 3.9.0
STEPS TO REPRODUCE
- community.mysql.mysql_user:
    name: "test"
    host: "test"
    password: "test"
    update_password: "on_new_username"
EXPECTED RESULTS
ACTUAL RESULTS
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: IndexError: tuple index out of range
fatal: [testhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"<stdin>\", line 141, in <module>\n  File \"<stdin>\", line 133, in _ansiballz_main\n  File \"<stdin>\", line 81, in invoke_module\n  File \"/usr/lib/python3.10/runpy.py\", line 224, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib/python3.10/runpy.py\", line 96, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/lib/python3.10/runpy.py\", line 86, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_mysql_user_payload_prkilmpt/ansible_mysql_user_payload.zip/ansible_collections/community/mysql/plugins/modules/mysql_user.py\", line 594, in <module>\n  File \"/tmp/ansible_mysql_user_payload_prkilmpt/ansible_mysql_user_payload.zip/ansible_collections/community/mysql/plugins/modules/mysql_user.py\", line 567, in main\n  File \"/tmp/ansible_mysql_user_payload_prkilmpt/ansible_mysql_user_payload.zip/ansible_collections/community/mysql/plugins/module_utils/user.py\", line 160, in user_add\n  File \"/tmp/ansible_mysql_user_payload_prkilmpt/ansible_mysql_user_payload.zip/ansible_collections/community/mysql/plugins/module_utils/user.py\", line 123, in get_existing_authentication\nIndexError: tuple index out of range\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}