summaryrefslogtreecommitdiff
path: root/database
diff options
context:
space:
mode:
authorSerge van Ginderachter <serge@vanginderachter.be>2016-08-04 17:17:10 +0200
committerToshio Kuratomi <a.badger@gmail.com>2016-08-04 08:17:10 -0700
commit9a47088d672ce4bcd423aa74f1d433a690f5688f (patch)
tree98f302945f1194ff8e7de499a2f580e7e218048e /database
parente9bbd3a4038f9572aa068096a84411b40a5d33f6 (diff)
downloadansible-modules-extras-9a47088d672ce4bcd423aa74f1d433a690f5688f.tar.gz
Exception handling for MySQLdb warnings (#2594)
Do not fail the module for warnings. Return warnings in the module result set. Fixes #719 Alternative to #720 and as discuseed over there.
Diffstat (limited to 'database')
-rw-r--r--database/mysql/mysql_replication.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/database/mysql/mysql_replication.py b/database/mysql/mysql_replication.py
index bdfcdbf1..b9a7d13c 100644
--- a/database/mysql/mysql_replication.py
+++ b/database/mysql/mysql_replication.py
@@ -274,6 +274,7 @@ def main():
elif mode in "changemaster":
chm=[]
chm_params = {}
+ result = {}
if master_host:
chm.append("MASTER_HOST=%(master_host)s")
chm_params['master_host'] = master_host
@@ -322,9 +323,12 @@ def main():
chm.append("MASTER_AUTO_POSITION = 1")
try:
changemaster(cursor, chm, chm_params)
+ except MySQLdb.Warning, e:
+ result['warning'] = str(e)
except Exception, e:
module.fail_json(msg='%s. Query == CHANGE MASTER TO %s' % (e, chm))
- module.exit_json(changed=True)
+ result['changed']=True
+ module.exit_json(**result)
elif mode in "startslave":
started = start_slave(cursor)
if started is True: