From 206087e342ebed4fa3d9c020553ae4233d512f0b Mon Sep 17 00:00:00 2001 From: Andrey Klychkov Date: Fri, 24 May 2019 19:31:47 +0300 Subject: [PATCH] Backport/2.8/56703 (#56829) * postgresql_db: bugfix 56703 (#56734) (cherry picked from commit f9108e23e7cb0141d8f6258e82585e327cd18805) * postgresql_db bugfix (backport/2.8/56703) --- .../fragments/56734-postgres_bugfix_pg_restore.yml | 2 ++ .../modules/database/postgresql/postgresql_db.py | 11 ++--------- 2 files changed, 4 insertions(+), 9 deletions(-) create mode 100644 changelogs/fragments/56734-postgres_bugfix_pg_restore.yml diff --git a/changelogs/fragments/56734-postgres_bugfix_pg_restore.yml b/changelogs/fragments/56734-postgres_bugfix_pg_restore.yml new file mode 100644 index 00000000000..1f64590890c --- /dev/null +++ b/changelogs/fragments/56734-postgres_bugfix_pg_restore.yml @@ -0,0 +1,2 @@ +bugfixes: +- postgresql_db - fix for postgresql_db fails if stderr contains output (https://github.com/ansible/ansible/issues/56703) diff --git a/lib/ansible/modules/database/postgresql/postgresql_db.py b/lib/ansible/modules/database/postgresql/postgresql_db.py index d533b7e9cd4..454d80a6464 100644 --- a/lib/ansible/modules/database/postgresql/postgresql_db.py +++ b/lib/ansible/modules/database/postgresql/postgresql_db.py @@ -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())