Problem: mysql_db ansible module tries to use tcp socket
mamedin opened this issue · 5 comments
It is a bug related to the mysql_db module.
The workaround is:
- Adding
socket=/var/run/mysqld/mysqld.sock
in/root/.my.cnf
to use the unix socket.
Error:
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: OperationalError: (1044, u"Access denied for user 'root'@'127.0.0.1' to database 'gnwt_test'")
fatal: [atom-test-sites -> None]: FAILED! => {"changed": false, "msg": "error creating database: (1044, u\"Access denied for user 'root'@'127.0.0.1' to database 'gnwt_test'\")"}
Seems related to ansible/ansible#47736 (comment)
When using MySQLdb it works fine, but fails when python-pymysql package is installed.
This command fixes the issue on atom-test-sites:
root@atom-test-sites:~# sudo apt-get remove python-pymysql
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
grub-pc-bin guile-2.0-libs libgc1c2 libgsasl7 libkyotocabinet16v5 libmailutils5 libntlm0 mailutils-common
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
python-pymysql
0 upgraded, 0 newly installed, 1 to remove and 18 not upgraded.
After this operation, 323 kB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 143514 files and directories currently installed.)
Removing python-pymysql (0.8.0-1) ...
The python-mysqldb
should be installed.
Looking at mysql_user documentation, the only requierement is (See https://docs.ansible.com/ansible/2.3/mysql_user_module.html):
Requirements (on host that executes module)
MySQLdb
So:
- Never use the pymysql packages, always use the mysqldb ones
This issue is fixed, but I prefer to leave it open: never use the pymysql packages
I'll try to review the molecule PR, it is very useful. Thanks!
Hi @mamedin , it's been a while since I did this PR: #73 but it could probably help with this issue? (the PR adds a login_unix_socket parameter to the mysql_user task)
Same change I did here this morning: artefactual-labs/ansible-atom-replication@e8db189