ansible-collections / community.mysql

MySQL Ansible Collection
https://galaxy.ansible.com/ui/repo/published/community/mysql/
Other
99 stars 87 forks source link

`check_hostname` not evaluated as boolean in `mysql_connect` #685

Open tchernomax opened 5 days ago

tchernomax commented 5 days ago
SUMMARY
    - community.mysql.mysql_replication:
        login_host: …
        login_user: …
        login_password: …
        check_hostname: false
        mode: getprimary

→ FAILED! => {"changed": false, "msg": "unable to connect to database, check login_user and login_password are correct or /root/.my.cnf has the credentials. Exception message: (1043, 'Bad handshake')"}

Same problem with

    - community.mysql.mysql_replication:
        login_host: …
        login_user: …
        login_password: …
        check_hostname: true
        mode: getprimary

But

    - community.mysql.mysql_replication:
        login_host: …
        login_user: …
        login_password: …
        mode: getprimary

→ OK

In fact https://github.com/ansible-collections/community.mysql/blob/a5afa1a375ebd7dc676ff6ab6f7323ce0b88b299/plugins/module_utils/mysql.py#L87 only test if check_hostname is None. So check_hostname=True or check_hostname=False produce exactly the same behavior.

ISSUE TYPE
COMPONENT NAME
ANSIBLE VERSION
ansible [core 2.17.5]
  config file = /home/max/.ansible.cfg
  configured module search path = ['/home/max/.ansible/modules']
  ansible python module location = /usr/lib/python3.12/site-packages/ansible
  ansible collection location = /home/max/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.12.7 (main, Oct  1 2024, 11:15:50) [GCC 14.2.1 20240910] (/usr/bin/python)
  jinja version = 3.1.4
  libyaml = True
COLLECTION VERSION
# /usr/lib/python3.12/site-packages/ansible_collections
Collection        Version
----------------- -------
community.general 9.5.0
CONFIGURATION
CONFIG_FILE() = /home/max/.ansible.cfg
DEFAULT_FORCE_HANDLERS(/home/max/.ansible.cfg) = True
DEFAULT_HOST_LIST(/home/max/.ansible.cfg) = ['/home/max/.ansible/oxalide-full-hosts']
DEFAULT_JINJA2_EXTENSIONS(/home/max/.ansible.cfg) = jinja2.ext.do
DEFAULT_MODULE_PATH(/home/max/.ansible.cfg) = ['/home/max/.ansible/modules']
DEFAULT_MODULE_UTILS_PATH(/home/max/.ansible.cfg) = ['/home/max/.ansible/module_utils']
DIFF_ALWAYS(/home/max/.ansible.cfg) = True
EDITOR(env: EDITOR) = nvim
INTERPRETER_PYTHON(/home/max/.ansible.cfg) = auto_silent
RETRY_FILES_ENABLED(/home/max/.ansible.cfg) = False
OS / ENVIRONMENT
STEPS TO REPRODUCE
    - community.mysql.mysql_replication:
        login_host: …
        login_user: …
        login_password: …
        check_hostname: false
        mode: getprimary
EXPECTED RESULTS

OK, no change.

ACTUAL RESULTS
FAILED! => {"changed": false, "msg": "unable to connect to database, check login_user and login_password are correct or /root/.my.cnf has the credentials. Exception message: (1043, 'Bad handshake')"}
Andersson007 commented 4 days ago

@tchernomax hi, thanks for reporting the issue! Would you like to investigate and possible fix it yourself or we can put the help_wanted label? There's the Quick start dev guide that can help.