ansible-role-mysql icon indicating copy to clipboard operation
ansible-role-mysql copied to clipboard

unable to find /root/.my.cnf. Exception message: (1045)

Open alainseys opened this issue 6 months ago • 1 comments

Hello,

Ansible version: core 2.17.11 Awx version: 24.5.0 Rockey Linux version: 9.5

I am encountering an issue while running the role.

Error Message: "msg": "unable to find /root/.my.cnf. Exception message: (1045, "Access denied for user 'ansible'@'localhost' (using password: NO)")"

This error occurs at the step: TASK [mysql : Ensure MySQL databases are present.]

Despite adding the user with NOPASSWD authentication, I am still receiving the same result (ansible ALL=(ALL) NOPASSWD: ALL)

I am triggering this using AWX, and the SSH user credentials are present, with the vault also bound.

Image

The role installs MySQL, but the database and users are not created because it hangs on the step: TASK [mysql : Ensure MySQL databases are present.] Detailed error from awx:

{ "msg": "unable to find /root/.my.cnf. Exception message: (1045, \"Access denied for user 'ansible'@'localhost' (using password: NO)\")", "invocation": { "module_args": { "name": [ "zabbix" ], "collation": "utf8mb4_0900_ai_ci", "encoding": "utf8mb4", "state": "present", "login_host": "localhost", "login_port": 3306, "config_file": "/root/.my.cnf", "connect_timeout": 30, "single_transaction": false, "quick": true, "ignore_tables": [], "hex_blob": false, "force": false, "master_data": 0, "skip_lock_tables": false, "use_shell": false, "unsafe_login_password": false, "restrict_config_file": false, "check_implicit_admin": false, "config_overrides_defaults": false, "pipefail": false, "login_user": null, "login_password": null, "login_unix_socket": null, "client_cert": null, "client_key": null, "ca_cert": null, "check_hostname": null, "target": null, "dump_extra_args": null, "chdir": null } }, "_ansible_no_log": false, "changed": false, "item": { "name": "test", "encoding": "utf8mb4", "collation": "utf8mb4_0900_ai_ci" }, "ansible_loop_var": "item", "_ansible_item_label": { "name": "test", "encoding": "utf8mb4", "collation": "utf8mb4_0900_ai_ci" } }

When i run the test with molecule evrything succeeds & debian is working as expected.

Please advice

alainseys avatar May 06 '25 09:05 alainseys

I think, the copying of my.cnf was escaped in the task Copy .my.cnf file with root password credentials because the condition on this task did not met. This happens when the variable rh_mysql_install_packages.changed has false value. I think your playbook run was interrupted between the installation of MySQL/MariaDB and the copying of my.cnf. Remove the Package an rerun your playbook again, it should work.

afeefghannam89 avatar May 23 '25 07:05 afeefghannam89

This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!

Please read this blog post to see the reasons why I mark issues as stale.

github-actions[bot] avatar Sep 20 '25 20:09 github-actions[bot]

This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details.

github-actions[bot] avatar Nov 22 '25 20:11 github-actions[bot]