mysql_db : how to specify the server port

I am trying to use the mysql_db module for the database creation in a following way:

  • name: Create Application Database
    mysql_db: name={{ dbname }} state=present login_host={{ db_server }} login_password={{ admin_password }} login_user={{ admin_user }}

and also

  • name: Create Application Database v2

mysql_db: name={{ dbname }} state=present login_host={{ db_server }}

My database is running on the port != 3306, so need to specify it somewhere.

I have put it into ~/.my.cnf and also into /etc/my.cnf, but the module mysql_db does not take it into account.

~/.my.cnf == /etc/my.cnf

[client]
port=5501
user=admin
password=ABRACADABRA

When using the command-line : mysql -h db-host-here I am connecting seamlessly

I am using RH Linux v6.4

The connection uisng python from the same host

import MySQLdb

db = MySQLdb.connect(host="…, port=5501)

works without any troubles

Thank you for your comments.

Have you tried servername:port ?

Yes, I did. No luck.
Looked into the source code. The port is not used at all.

Manieq

Ok please make sure there’s a ticket filed on this one.

I believe it will respect your my.cnf but I don’t think that should be required personally.

I’m generally a PostgreSQL user so perhaps the various folks who work on/with this module would like to work on this.

No problem. Please explain me how do I create / add a ticket?
I did not do it in the past. Here or on the github?

Thanks,
Manieq

Issues · ansible/ansible · GitHub

!image.png|109x42