mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
postgresql_db - Handle pg_dump return code (#52985)
Handle return code return by pg_dump command Fixes: #40424
This commit is contained in:
parent
f0ef4dae05
commit
d30879a0b7
2 changed files with 11 additions and 2 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- postgresql_db - the module fails not always when pg_dump errors occured (https://github.com/ansible/ansible/issues/40424).
|
|
@ -501,9 +501,16 @@ def main():
|
||||||
try:
|
try:
|
||||||
rc, stdout, stderr, cmd = method(module, target, target_opts, db, **kw)
|
rc, stdout, stderr, cmd = method(module, target, target_opts, db, **kw)
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
module.fail_json(msg=stderr, stdout=stdout, rc=rc, cmd=cmd)
|
module.fail_json(msg='Dump of database %s failed' % db,
|
||||||
|
stdout=stdout, stderr=stderr, rc=rc, cmd=cmd)
|
||||||
|
|
||||||
|
elif stderr and 'warning' not in str(stderr):
|
||||||
|
module.fail_json(msg='Dump of database %s failed' % db,
|
||||||
|
stdout=stdout, stderr=stderr, rc=1, cmd=cmd)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
module.exit_json(changed=True, msg=stdout, stderr=stderr, rc=rc, cmd=cmd)
|
module.exit_json(changed=True, msg='Dump of database %s has been done' % db,
|
||||||
|
stdout=stdout, stderr=stderr, rc=rc, cmd=cmd)
|
||||||
except SQLParseError as e:
|
except SQLParseError as e:
|
||||||
module.fail_json(msg=to_native(e), exception=traceback.format_exc())
|
module.fail_json(msg=to_native(e), exception=traceback.format_exc())
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue