ansible-collections / community.mysql

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

"unable to connect to database, check login_user and login_password are correct" #230

Closed skjbulcher closed 3 years ago

skjbulcher commented 3 years ago
SUMMARY

I am fairly new to Ansible, so this may just be me, but I can't figure out how to connect to get mysql info. I'm using the plugin as part of the larger devsec.hardening package to secure a MariaDB installation. The install is brand new, so I can access the MariaDB client using sudo mysql -uroot. I also figured out how to run other Ansible tasks on the target computer.

- name: MariaDB Version
  become: yes
  become_method: sudo
  community.mysql.mysql_info:
    filter: version
    login_unix_socket: "{{ login_unix_socket | default(omit) }}"

results in:

TASK [requirements : MariaDB Version] *************************************************************************************************************
fatal: [atlas-dev.ebs.llc]: 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: (1698, \"Access denied for user 'root'@'localhost'\")"}
ISSUE TYPE
COMPONENT NAME

community.mysql.mysql_info

ANSIBLE VERSION
ansible 2.9.6
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.8.10 (default, Sep 28 2021, 16:10:42) [GCC 9.3.0]
COLLECTION VERSION
usage: ansible-galaxy collection [-h] COLLECTION_ACTION ...
ansible-galaxy collection: error: argument COLLECTION_ACTION: invalid choice: 'list' (choose from 'init', 'build', 'publish', 'install')
CONFIGURATION
# no data
OS / ENVIRONMENT

Ubuntu 20.04

Andersson007 commented 3 years ago

@skjbulcher hi, thanks for reporting the issue!

1) Could you please try this with the latest Ansible version if possible OR 2) using the latest version of the collection See https://github.com/ansible-collections/community.mysql/blob/main/README.md.

I'm not 100% sure if this help but there have been a lot of changes introduced since that.

3) If this doesn't help, could you please try to add login_user: root to the task.

Anyway please let us know the result.

Andersson007 commented 3 years ago
  1. Also i would try to eliminate login_unix_socket: ... if the previous steps didn't help (to localize the issue).
Andersson007 commented 3 years ago

@skjbulcher , has anything helped? ^

skjbulcher commented 3 years ago

@skjbulcher , has anything helped? ^

I did end up installing the latest version of ansible a couple days ago. This is a bug (in the version of ansible?) that comes in Ubuntu 20.04's repository.

Andersson007 commented 3 years ago

@skjbulcher so if this helps, that's cool, thanks for the feedback!