Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mysql_info module do not return information about mysql replication when it configured on hosts #682

Open
only-RMK opened this issue Oct 9, 2024 · 3 comments

Comments

@only-RMK
Copy link

only-RMK commented Oct 9, 2024

SUMMARY

mysql_info module failing:

  • when you want to get replication info on primary host using filter slave_hosts;
  • when you want to get replication info on replica host using filter slave_status.
ISSUE TYPE
  • Bug Report
COMPONENT NAME

mysql_info

ANSIBLE VERSION
ansible [core 2.17.5]
  python version = 3.12.7 (main, Oct  1 2024, 02:05:46) [Clang 16.0.0 (clang-1600.0.26.3)]
  jinja version = 3.1.4
COLLECTION VERSION
Collection      Version
--------------- -------
community.mysql 3.10.3
STEPS TO REPRODUCE
  • Run to instances with replication Primary -> Replica (Master -> Slave);
  • Run ansible ad-hoc command on primary host:
    ansible <primary host> -m mysql_info -a 'filter=slave_hosts'
  • Run ansible ad-hoc command on replica host:
    ansible <replica host> -m mysql_info -a 'filter=slave_status'
EXPECTED RESULTS

Return required data.

ACTUAL RESULTS
"module_stderr": "Traceback (most recent call last):\n  File \"<stdin>\", line 107, in <module>\n  File \"<stdin>\", line 99, in _ansiballz_main\n  File \"<stdin>\", line 47, in invoke_module\n  File \"/usr/lib/python3.9/runpy.py\", line 210, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib/python3.9/runpy.py\", line 97, in _run_module_code\n_run_code(code, mod_globals, init_globals,\n  File \"/usr/lib/python3.9/runpy.py\", line 87, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_mysql_info_payload_2q_s7u3e/ansible_mysql_info_payload.zip/ansible_collections/community/mysql/plugins/modules/mysql_info.py\", line 787, in <module>\n  File \"/tmp/ansible_mysql_info_payload_2q_s7u3e/ansible_mysql_info_payload.zip/ansible_collections/community/mysql/plugins/modules/mysql_info.py\", line 783, in main\n  File \"/tmp/ansible_mysql_info_payload_2q_s7u3e/ansible_mysql_info_payload.zip/ansible_collections/community/mysql/plugins/modules/mysql_info.py\", line 388, in get_info\n  File \"/tmp/ansible_mysql_info_payload_2q_s7u3e/ansible_mysql_info_payload.zip/ansible_collections/community/mysql/plugins/modules/mysql_info.py\", line 435, in __collect\n  File \"/tmp/ansible_mysql_info_payload_2q_s7u3e/ansible_mysql_info_payload.zip/ansible_collections/community/mysql/plugins/modules/mysql_info.py\", line 545, in __get_slaves\nKeyError: 'Server_id'\n"

"module_stderr": "Traceback (most recent call last):\n  File \"<stdin>\", line 107, in <module>\n  File \"<stdin>\", line 99, in _ansiballz_main\n  File \"<stdin>\", line 47, in invoke_module\n  File \"<frozen runpy>\", line 226, in run_module\n  File \"<frozen runpy>\", line 98, in _run_module_code\n  File \"<frozen runpy>\", line 88, in _run_code\n  File \"/tmp/ansible_mysql_info_payload_6nsn_pqi/ansible_mysql_info_payload.zip/ansible_collections/community/mysql/plugins/modules/mysql_info.py\", line 787, in <module>\n  File \"/tmp/ansible_mysql_info_payload_6nsn_pqi/ansible_mysql_info_payload.zip/ansible_collections/community/mysql/plugins/modules/mysql_info.py\", line 783, in main\n  File \"/tmp/ansible_mysql_info_payload_6nsn_pqi/ansible_mysql_info_payload.zip/ansible_collections/community/mysql/plugins/modules/mysql_info.py\", line 388, in get_info\n  File \"/tmp/ansible_mysql_info_payload_6nsn_pqi/ansible_mysql_info_payload.zip/ansible_collections/community/mysql/plugins/modules/mysql_info.py\", line 432, in __collect\n  File \"/tmp/ansible_mysql_info_payload_6nsn_pqi/ansible_mysql_info_payload.zip/ansible_collections/community/mysql/plugins/modules/mysql_info.py\", line 523, in __get_slave_status\nKeyError: 'Master_Host'\n"
@only-RMK
Copy link
Author

I tested and latest pymysql versions, but still result is the same.
I check older versions of collections, but only 3.9.0 collection version works correctly for me.

@laurent-indermuehle
Copy link
Collaborator

Hi @only-RMK,
What is your db engine and version? Is MySQL 8.x or MariaDB 10.x?

As a workaround, I think you can get the same info using the mysql_replication module.

@only-RMK
Copy link
Author

Hi @laurent-indermuehle,
I use Percona Server for MySQL 8.0.39-30, my roles use mysql_info to get replication status, replications host list and etc, mysql_replication module do not return same data as mysql_info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants