mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
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.
This commit is contained in:
parent
4fc6fc438a
commit
121ef13e47
1 changed files with 5 additions and 1 deletions
|
@ -274,6 +274,7 @@ def main():
|
||||||
elif mode in "changemaster":
|
elif mode in "changemaster":
|
||||||
chm=[]
|
chm=[]
|
||||||
chm_params = {}
|
chm_params = {}
|
||||||
|
result = {}
|
||||||
if master_host:
|
if master_host:
|
||||||
chm.append("MASTER_HOST=%(master_host)s")
|
chm.append("MASTER_HOST=%(master_host)s")
|
||||||
chm_params['master_host'] = master_host
|
chm_params['master_host'] = master_host
|
||||||
|
@ -322,9 +323,12 @@ def main():
|
||||||
chm.append("MASTER_AUTO_POSITION = 1")
|
chm.append("MASTER_AUTO_POSITION = 1")
|
||||||
try:
|
try:
|
||||||
changemaster(cursor, chm, chm_params)
|
changemaster(cursor, chm, chm_params)
|
||||||
|
except MySQLdb.Warning, e:
|
||||||
|
result['warning'] = str(e)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
module.fail_json(msg='%s. Query == CHANGE MASTER TO %s' % (e, chm))
|
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":
|
elif mode in "startslave":
|
||||||
started = start_slave(cursor)
|
started = start_slave(cursor)
|
||||||
if started is True:
|
if started is True:
|
||||||
|
|
Loading…
Reference in a new issue