Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

mysql user fails when the hostname has capital letters #1386

Closed
muelli opened this issue May 21, 2015 · 3 comments
Closed

mysql user fails when the hostname has capital letters #1386

muelli opened this issue May 21, 2015 · 3 comments

Comments

@muelli
Copy link

muelli commented May 21, 2015

According to debops/debops#113, a puppet-esque workaround would be for ansible to lower the hostname before entering it into the database. Right now, neither user_exists nor user_add do not lower the hostname: https://github.com/ansible/ansible-modules-core/blob/devel/database/mysql/mysql_user.py#L210

@Jmainguy
Copy link
Contributor

So it creates the user using lowercase already, but it doesn't check if the lowercase name is created already, so it tries to create it again on subsequent runs. The fix will be to change the checking portion of the code, user_exists presumably. This was tested on centos6.

[root@phy01 ansible]# ansible -i hosts -m mysql_user -a "name=jon host=JON.SOH.RE password=neat" all
ca.soh.re | success >> {
    "changed": true,
    "user": "jon"
}

[root@phy01 ansible]# ansible -i hosts -m mysql_user -a "name=jon host=JON.SOH.RE password=neat" all
ca.soh.re | FAILED >> {
    "failed": true,
    "msg": "(1396, \"Operation CREATE USER failed for 'jon'@'jon.soh.re'\")"
}

[root@phy01 ansible]# ansible -i hosts -m mysql_user -a "name=jon host=jon.soh.re password=neat" all
ca.soh.re | success >> {
    "changed": false,
    "user": "jon"
}

@Jmainguy
Copy link
Contributor

@muelli give #1390 a shot and see if it works for you.

Seems to work for me on centos now.

[root@phy01 ansible]# ansible -i hosts -m mysql_user -a "name=jon host=JON.SOH.RE password=neat state=present" all                                                                            
ca.soh.re | success >> {
    "changed": true,
    "user": "jon"
}

[root@phy01 ansible]# ansible -i hosts -m mysql_user -a "name=jon host=JON.SOH.RE password=neat state=present" all
ca.soh.re | success >> {
    "changed": false,
    "user": "jon"
}

@abadger
Copy link
Contributor

abadger commented May 21, 2015

Closing This Ticket

Hi!

We believe recent commits (likely detailed above) should resolve this question or problem for you.

This will also be included in the next major release.

If you continue seeing any problems related to this issue, or if you have any further questions, please let us know by stopping by one of the two mailing lists, as appropriate:

Because this project is very active, we're unlikely to see comments made on closed tickets, but the mailing list is a great way to ask questions, or post if you don't think this particular
issue is resolved.

Thank you!

@abadger abadger closed this as completed May 21, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants