Skip to content

Root password tasks not working well on localhost #20

@ktaragorn

Description

@ktaragorn

This is on LXLE which is based on ubuntu 14.04.1
The first time I run the task, I get

TASK: [ANXS.mysql | MySQL | Set the root password.] *************************** 
failed: [localhost] => (item=KarthikT-OptiPlex-GX620) => {"failed": true, "item": "KarthikT-OptiPlex-GX620", "parsed": false}
invalid output was: SUDO-SUCCESS-qhgbcpxzorscvhhvhgbmobqdlkyxzxvq
Traceback (most recent call last):
  File "/home/karthikt/.ansible/tmp/ansible-tmp-1412493609.88-146177631411431/mysql_user", line 1562, in <module>
    main()
  File "/home/karthikt/.ansible/tmp/ansible-tmp-1412493609.88-146177631411431/mysql_user", line 459, in main
    changed = user_add(cursor, user, host, password, priv)
  File "/home/karthikt/.ansible/tmp/ansible-tmp-1412493609.88-146177631411431/mysql_user", line 158, in user_add
    cursor.execute("CREATE USER %s@%s IDENTIFIED BY %s", (user,host,password))
  File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 174, in execute
    self.errorhandler(self, exc, value)
  File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
_mysql_exceptions.OperationalError: (1396, "Operation CREATE USER failed for 'root'@'karthikt-optiplex-gx620'")

changed: [localhost] => (item=127.0.0.1)
changed: [localhost] => (item=::1)
changed: [localhost] => (item=localhost)

FATAL: all hosts have already failed -- aborting

Which means the second time I get

TASK: [ANXS.mysql | MySQL | Set the root password.] *************************** 
failed: [localhost] => (item=KarthikT-OptiPlex-GX620) => {"failed": true, "item": "KarthikT-OptiPlex-GX620"}
msg: unable to connect to database, check login_user and login_password are correct or ~/.my.cnf has the credentials
failed: [localhost] => (item=127.0.0.1) => {"failed": true, "item": "127.0.0.1"}
msg: unable to connect to database, check login_user and login_password are correct or ~/.my.cnf has the credentials
failed: [localhost] => (item=::1) => {"failed": true, "item": "::1"}
msg: unable to connect to database, check login_user and login_password are correct or ~/.my.cnf has the credentials
failed: [localhost] => (item=localhost) => {"failed": true, "item": "localhost"}
msg: unable to connect to database, check login_user and login_password are correct or ~/.my.cnf has the credentials

FATAL: all hosts have already failed -- aborting

This works fine on a remote system.

As I write this (:P), I notice that the first Item is "item": "KarthikT-OptiPlex-GX620 which I believe was the name set by the ubuntu/lxle installer..
This would mean that it is picking the wrong task of the two tasks Set the root password. in tasks/secure.yml. First fix would be to name them differently based on their use (localhost vs remote perhaps). And perhaps a better check is needed rather than when: ansible_hostname != 'localhost' ?

This was repeatedly encountered, after purging mysql as shown in http://stackoverflow.com/questions/10853004/removing-mysql-5-5-completely. It is running the ansible galaxy version of the role.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions