1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Merge pull request #1317 from abondis/fix_mysql_db

fix issue with mysql authentication and states not dump or import
This commit is contained in:
Michael DeHaan 2012-10-12 14:26:45 -07:00
commit a82522a5c4

View file

@ -180,18 +180,21 @@ def main():
elif login_password is None or login_user is None:
module.fail_json(msg="when supplying login arguments, both login_user and login_password must be provided")
if state in ['dump','import']:
if target is None:
module.fail_json(msg="with state={0} target is required".format(state))
connect_to_db = db
else:
connect_to_db = 'mysql'
try:
if module.params["login_unix_socket"] != None:
db_connection = MySQLdb.connect(host=module.params["login_host"], unix_socket=module.params["login_unix_socket"], user=login_user, passwd=login_password, db=db)
db_connection = MySQLdb.connect(host=module.params["login_host"], unix_socket=module.params["login_unix_socket"], user=login_user, passwd=login_password, db=connect_to_db)
else:
db_connection = MySQLdb.connect(host=module.params["login_host"], user=login_user, passwd=login_password, db=db)
db_connection = MySQLdb.connect(host=module.params["login_host"], user=login_user, passwd=login_password, db=connect_to_db)
cursor = db_connection.cursor()
except Exception as e:
module.fail_json(msg="unable to connect, check login_user and login_password are correct, or alternatively check ~/.my.cnf contains credentials")
if (state in ['dump','import']) and target is None:
module.fail_json(msg="with state={0} target is required".format(state))
changed = False
if db_exists(cursor, db):
if state == "absent":