Added exception handling to database creation and deletion. Fixes #8075.
This commit is contained in:
parent
3d2b201cf9
commit
6e237bed7a
1 changed files with 8 additions and 2 deletions
|
@ -319,7 +319,10 @@ def main():
|
||||||
changed = False
|
changed = False
|
||||||
if db_exists(cursor, db):
|
if db_exists(cursor, db):
|
||||||
if state == "absent":
|
if state == "absent":
|
||||||
|
try:
|
||||||
changed = db_delete(cursor, db)
|
changed = db_delete(cursor, db)
|
||||||
|
except Exception, e:
|
||||||
|
module.fail_json(msg="error deleting database: " + str(e))
|
||||||
elif state == "dump":
|
elif state == "dump":
|
||||||
rc, stdout, stderr = db_dump(module, login_host, login_user,
|
rc, stdout, stderr = db_dump(module, login_host, login_user,
|
||||||
login_password, db, target,
|
login_password, db, target,
|
||||||
|
@ -340,7 +343,10 @@ def main():
|
||||||
module.exit_json(changed=True, db=db, msg=stdout)
|
module.exit_json(changed=True, db=db, msg=stdout)
|
||||||
else:
|
else:
|
||||||
if state == "present":
|
if state == "present":
|
||||||
|
try:
|
||||||
changed = db_create(cursor, db, encoding, collation)
|
changed = db_create(cursor, db, encoding, collation)
|
||||||
|
except Exception, e:
|
||||||
|
module.fail_json(msg="error creating database: " + str(e))
|
||||||
|
|
||||||
module.exit_json(changed=changed, db=db)
|
module.exit_json(changed=changed, db=db)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue