Skip to content

Commit

Permalink
Backport/2.8/56703 (#56829)
Browse files Browse the repository at this point in the history
* postgresql_db: bugfix 56703 (#56734)

(cherry picked from commit f9108e2)

* postgresql_db bugfix (backport/2.8/56703)
  • Loading branch information
Andersson007 authored and abadger committed May 24, 2019
1 parent 6c078e1 commit 206087e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/56734-postgres_bugfix_pg_restore.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- postgresql_db - fix for postgresql_db fails if stderr contains output (https://github.com/ansible/ansible/issues/56703)
11 changes: 2 additions & 9 deletions lib/ansible/modules/database/postgresql/postgresql_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,16 +539,9 @@ def main():
try:
rc, stdout, stderr, cmd = method(module, target, target_opts, db, **kw)
if rc != 0:
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)

module.fail_json(msg=stderr, stdout=stdout, rc=rc, cmd=cmd)
else:
module.exit_json(changed=True, msg='Dump of database %s has been done' % db,
stdout=stdout, stderr=stderr, rc=rc, cmd=cmd)
module.exit_json(changed=True, msg=stdout, stderr=stderr, rc=rc, cmd=cmd)
except SQLParseError as e:
module.fail_json(msg=to_native(e), exception=traceback.format_exc())

Expand Down

0 comments on commit 206087e

Please sign in to comment.