Improved output of mysql_db plugin
Show error number and error description on connect error to ease debugging.
This commit is contained in:
parent
a960caae96
commit
8f8109f1e0
1 changed files with 2 additions and 2 deletions
|
@ -346,11 +346,11 @@ def main():
|
||||||
db_connection = MySQLdb.connect(host=module.params["login_host"], port=login_port, user=login_user, passwd=login_password, db=connect_to_db)
|
db_connection = MySQLdb.connect(host=module.params["login_host"], port=login_port, user=login_user, passwd=login_password, db=connect_to_db)
|
||||||
cursor = db_connection.cursor()
|
cursor = db_connection.cursor()
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
|
errno, errstr = e.args
|
||||||
if "Unknown database" in str(e):
|
if "Unknown database" in str(e):
|
||||||
errno, errstr = e.args
|
|
||||||
module.fail_json(msg="ERROR: %s %s" % (errno, errstr))
|
module.fail_json(msg="ERROR: %s %s" % (errno, errstr))
|
||||||
else:
|
else:
|
||||||
module.fail_json(msg="unable to connect, check login credentials (login_user, and login_password, which can be defined in ~/.my.cnf), check that mysql socket exists and mysql server is running")
|
module.fail_json(msg="unable to connect, check login credentials (login_user, and login_password, which can be defined in ~/.my.cnf), check that mysql socket exists and mysql server is running (ERROR: %s %s)" % (errno, errstr))
|
||||||
|
|
||||||
changed = False
|
changed = False
|
||||||
if db_exists(cursor, db):
|
if db_exists(cursor, db):
|
||||||
|
|
Loading…
Reference in a new issue