Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix failing fail_json call in postgresql_schema #21495

Merged
merged 2 commits into from
Feb 16, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/ansible/modules/database/postgresql/postgresql_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@
sample: "acme"
'''


try:
import psycopg2
import psycopg2.extras
Expand All @@ -110,6 +109,10 @@
else:
postgresqldb_found = True

import traceback

from ansible.module_utils._text import to_native

class NotSupportedError(Exception):
pass

Expand Down Expand Up @@ -231,7 +234,7 @@ def main():
cursor_factory=psycopg2.extras.DictCursor)
except Exception:
e = get_exception()
module.fail_json(msg="unable to connect to database: %s" %(text, str(e)))
module.fail_json(msg="unable to connect to database: %s" % to_native(e), exception=traceback.format_exc())

try:
if module.check_mode:
Expand Down Expand Up @@ -262,7 +265,7 @@ def main():
raise
except Exception:
e = get_exception()
module.fail_json(msg="Database query failed: %s" %(text, str(e)))
module.fail_json(msg="Database query failed: %s" % to_native(e), exception=traceback.format_exc())

module.exit_json(changed=changed, schema=schema)

Expand Down