My ansible 2.9.10-1.el7 connects to the target machines as root.
On my target machines, I have /root/.my.cnf with a root password defined
under the section [mysql].
Here is the playbook and response
- hosts: databaseservers
tasks:
- name: add user to mysql
mysql_user:
name: "{{ name }}"
host: "{{ item }}"
password: "{{ password }}"
encrypted: no
priv: '*.*:ALL'
login_unix_socket: /var/lib/mysql/mysql.sock
state: present
with_items:
- localhost
- 127.0.0.1
- ::1
and I get...
failed: [awsbeta.happysoftware.com] (item=localhost) =>
{"ansible_loop_var": "item", "changed": false, "item": "localhost", "msg":
"unable to connect to database, check login_user and login_password are
correct or /root/.my.cnf has the credentials. Exception message: (1045,
u\"Access denied for user 'root'@'localhost' (using password: NO)\")"}
Note that using password is NO.
Most of the posts here concern setting the root password. One fellow, from
2016, questioned on what path the .my.cnf needed to be. Since I log in as
root, I figure it's /root/.my.cnf.
My /root/.my.cnf is:
[mysql]
user=root
password=xxxxxxxxxxx
[mysqldump]
user=databasebackup
password=xxxxxxxxxxx
Do I need another section, perhaps? What else might be wrong?
Thanks,
Ed Greenberg
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/bd2ec9d1-3259-4220-b365-587e220c5a5an%40googlegroups.com.