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_replication (Warning with "mode: getslave" that ansible translates as an error) #88

Closed
AshDevilRed opened this issue Jan 13, 2021 · 2 comments

Comments

@AshDevilRed
Copy link

SUMMARY

I want to get the slave status with mysql_replication module. (mode: getslave)
I'm on CentOS8, and it sends me back an error. (Warning > Error)
Because the "show slave status" command is deprecated. (Warning)
And Ansible seeing the warning gives me an error.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

module : mysql_replication

ANSIBLE VERSION
ansible --version
ansible 2.9.16
  config file = /home/vagrant/.ansible.cfg
  configured module search path = ['/home/vagrant/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.6/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.6.8 (default, May 21 2019, 23:51:36) [GCC 8.2.1 20180905 (Red Hat 8.2.1-3)]
CONFIGURATION
ansible-config dump --only-changed
DEFAULT_CALLBACK_WHITELIST(/home/vagrant/.ansible.cfg) = ['profile_tasks']
DEFAULT_HOST_LIST(/home/vagrant/.ansible.cfg) = ['/home/vagrant/hosts']
DEFAULT_LOG_PATH(/home/vagrant/.ansible.cfg) = /tmp/ansible.log
DEFAULT_MANAGED_STR(/home/vagrant/.ansible.cfg) = This file is managed by Ansible, all changes will be lost
DEFAULT_ROLES_PATH(/home/vagrant/.ansible.cfg) = ['/home/vagrant/ansible/roles']
DEFAULT_TIMEOUT(/home/vagrant/.ansible.cfg) = 30
OS / ENVIRONMENT

OS version :
CentOS Linux release 8.0.1905 (Core)

Mysql Version :
mysql Ver 8.0.22-13 for Linux on x86_64 (Percona Server (GPL), Release 13, Revision 6f7822f)

STEPS TO REPRODUCE

You just have to use the task below on a CentOS8.
You can remove the last line and change the login_password to "root" for the test.

- name: Vérification du status du slave
  become: yes
  mysql_replication:
    login_user: "root"
    login_password: "{{ mysql_root_passwd }}"
    mode: getslave
  register: slave
  when: hostvars[inventory_hostname].mysql_slave_of is defined
EXPECTED RESULTS

I want to register the state of the replication in the slave variable. To run the replication if it's not already started.

ACTUAL RESULTS

The warning "Warning: (1287, "'SHOW SLAVE STATUS' is deprecated and will be removed in a future release. Please use SHOW REPLICA STATUS instead" give me an error.

The full traceback is:
Traceback (most recent call last):
  File "/home/vagrant/.ansible/tmp/ansible-tmp-1610527583.322707-5953-181209673675437/AnsiballZ_mysql_replication.py", line 102, in <module>
    _ansiballz_main()
  File "/home/vagrant/.ansible/tmp/ansible-tmp-1610527583.322707-5953-181209673675437/AnsiballZ_mysql_replication.py", line 94, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/home/vagrant/.ansible/tmp/ansible-tmp-1610527583.322707-5953-181209673675437/AnsiballZ_mysql_replication.py", line 40, in invoke_module
    runpy.run_module(mod_name='ansible.modules.database.mysql.mysql_replication', init_globals=None, run_name='__main__', alter_sys=True)
  File "/usr/lib64/python3.6/runpy.py", line 205, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib64/python3.6/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_mysql_replication_payload_y9efiht0/ansible_mysql_replication_payload.zip/ansible/modules/database/mysql/mysql_replication.py", line 373, in <module>
  File "/tmp/ansible_mysql_replication_payload_y9efiht0/ansible_mysql_replication_payload.zip/ansible/modules/database/mysql/mysql_replication.py", line 279, in main
  File "/tmp/ansible_mysql_replication_payload_y9efiht0/ansible_mysql_replication_payload.zip/ansible/modules/database/mysql/mysql_replication.py", line 148, in get_slave_status
  File "/usr/lib/python3.6/site-packages/pymysql/cursors.py", line 165, in execute
    result = self._query(query)
  File "/usr/lib/python3.6/site-packages/pymysql/cursors.py", line 322, in _query
    self._do_get_result()
  File "/usr/lib/python3.6/site-packages/pymysql/cursors.py", line 376, in _do_get_result
    super(DictCursorMixin, self)._do_get_result()
  File "/usr/lib/python3.6/site-packages/pymysql/cursors.py", line 338, in _do_get_result
    self._show_warnings()
  File "/usr/lib/python3.6/site-packages/pymysql/cursors.py", line 354, in _show_warnings
    warnings.warn(err.Warning(*w[1:3]), stacklevel=4)
pymysql.err.Warning: (1287, "'SHOW SLAVE STATUS' is deprecated and will be removed in a future release. Please use SHOW REPLICA STATUS instead")
fatal: [dbservers02]: FAILED! => {
    "changed": false,
    "module_stderr": "OpenSSH_7.8p1, OpenSSL 1.1.1 FIPS  11 Sep 2018\r\ndebug1: Reading configuration data /home/vagrant/.ssh/config\r\ndebug1: /home/vagrant/.ssh/config line 5: Applying options for 10.0.242.*\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug3: /etc/ssh/ssh_config line 52: Including file /etc/ssh/ssh_config.d/05-redhat.conf depth 0\r\ndebug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf\r\ndebug3: /etc/ssh/ssh_config.d/05-redhat.conf line 2: Including file /etc/crypto-policies/back-ends/openssh.config depth 1\r\ndebug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config\r\ndebug3: gss kex names ok: [gss-gex-sha1-,gss-group14-sha1-]\r\ndebug3: kex names ok: [[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1]\r\ndebug1: /etc/ssh/ssh_config.d/05-redhat.conf line 8: Applying options for *\r\ndebug2: resolve_canonicalize: hostname 10.0.242.13 is address\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 5 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 4680\r\ndebug3: mux_client_request_session: session request sent\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 1\r\nShared connection to 10.0.242.13 closed.\r\n",
    "module_stdout": "Traceback (most recent call last):\r\n  File \"/home/vagrant/.ansible/tmp/ansible-tmp-1610527583.322707-5953-181209673675437/AnsiballZ_mysql_replication.py\", line 102, in <module>\r\n    _ansiballz_main()\r\n  File \"/home/vagrant/.ansible/tmp/ansible-tmp-1610527583.322707-5953-181209673675437/AnsiballZ_mysql_replication.py\", line 94, in _ansiballz_main\r\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n  File \"/home/vagrant/.ansible/tmp/ansible-tmp-1610527583.322707-5953-181209673675437/AnsiballZ_mysql_replication.py\", line 40, in invoke_module\r\n    runpy.run_module(mod_name='ansible.modules.database.mysql.mysql_replication', init_globals=None, run_name='__main__', alter_sys=True)\r\n  File \"/usr/lib64/python3.6/runpy.py\", line 205, in run_module\r\n    return _run_module_code(code, init_globals, run_name, mod_spec)\r\n  File \"/usr/lib64/python3.6/runpy.py\", line 96, in _run_module_code\r\n    mod_name, mod_spec, pkg_name, script_name)\r\n  File \"/usr/lib64/python3.6/runpy.py\", line 85, in _run_code\r\n    exec(code, run_globals)\r\n  File \"/tmp/ansible_mysql_replication_payload_y9efiht0/ansible_mysql_replication_payload.zip/ansible/modules/database/mysql/mysql_replication.py\", line 373, in <module>\r\n  File \"/tmp/ansible_mysql_replication_payload_y9efiht0/ansible_mysql_replication_payload.zip/ansible/modules/database/mysql/mysql_replication.py\", line 279, in main\r\n  File \"/tmp/ansible_mysql_replication_payload_y9efiht0/ansible_mysql_replication_payload.zip/ansible/modules/database/mysql/mysql_replication.py\", line 148, in get_slave_status\r\n  File \"/usr/lib/python3.6/site-packages/pymysql/cursors.py\", line 165, in execute\r\n    result = self._query(query)\r\n  File \"/usr/lib/python3.6/site-packages/pymysql/cursors.py\", line 322, in _query\r\n    self._do_get_result()\r\n  File \"/usr/lib/python3.6/site-packages/pymysql/cursors.py\", line 376, in _do_get_result\r\n    super(DictCursorMixin, self)._do_get_result()\r\n  File \"/usr/lib/python3.6/site-packages/pymysql/cursors.py\", line 338, in _do_get_result\r\n    self._show_warnings()\r\n  File \"/usr/lib/python3.6/site-packages/pymysql/cursors.py\", line 354, in _show_warnings\r\n    warnings.warn(err.Warning(*w[1:3]), stacklevel=4)\r\npymysql.err.Warning: (1287, \"'SHOW SLAVE STATUS' is deprecated and will be removed in a future release. Please use SHOW REPLICA STATUS instead\")\r\n",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

@Andersson007
Copy link
Collaborator

Andersson007 commented Jan 13, 2021

@AshDevilRed thanks for reporting this
It's been already fixed in #71
The collection tarbal containing the fix is available here.

Alternatively, the collection is shipped with Ansible 2.10 (2.10.5 contains the changes).

If you don't like to upgrade, 2.9 supports collections as well. Please download the tarbal and install it using this official manual.

Thanks!

@Andersson007
Copy link
Collaborator

@AshDevilRed , I'll close the issue. See the comment above. If you try and confirm that everything is OK (or not OK), it would be really great. Thanks!

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