Backport/2.8/56703 (#56829)

* postgresql_db: bugfix 56703 (#56734)

(cherry picked from commit f9108e23e7)

* postgresql_db bugfix (backport/2.8/56703)
This commit is contained in:
Andrey Klychkov 2019-05-24 19:31:47 +03:00 committed by Toshio Kuratomi
parent 6c078e18a8
commit 206087e342
2 changed files with 4 additions and 9 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- postgresql_db - fix for postgresql_db fails if stderr contains output (https://github.com/ansible/ansible/issues/56703)

View file

@ -539,16 +539,9 @@ 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='Dump of database %s failed' % db, module.fail_json(msg=stderr, stdout=stdout, rc=rc, cmd=cmd)
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='Dump of database %s has been done' % db, module.exit_json(changed=True, msg=stdout, stderr=stderr, rc=rc, cmd=cmd)
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())