community.general/lib/ansible
Ted Timmons a000594436 fix failing fail_json call in postgresql_schema (#21495)
fix failing fail_json call in postgresql_schema

- Bugfix Pull Request

modules/database/postgresql/postgresql_schema

```
2.3.0
```

Here's an example of the error that was coming out. Massaged some linebreaks and backslashes to make it more readable:

    "module_stderr": "Traceback (most recent call last):
      File "/tmp/ansible_3X05GE/ansible_module_postgresql_schema.py", line 274, in <module>
        main()
      File "/tmp/ansible_3X05GE/ansible_module_postgresql_schema.py", line 265, in main
        module.fail_json(msg="Database query failed: %s" %(text, str(e)))
      NameError: global name 'text' is not defined
    ",

Now it triggers with the correct exception and shows the traceback. This duplication of str(e) and traceback seems to be the best design pattern.

Sample of the new output:

    An exception occurred during task execution. The full traceback is:
    Traceback (most recent call last):
      File "/tmp/ansible_gp4v1Q/ansible_module_postgresql_schema.py", line 254, in main
        changed = schema_create(cursor, schema, owner)
    ...
        return super(DictCursor, self).execute(query, vars)
    ProgrammingError: permission denied for database schemadb

    fatal: [localhost]: FAILED! => {
        "changed": false,
        "failed": true,
    ...
        },
        "msg": "Database query failed: permission denied for database schemadb\n"
2017-02-16 11:26:40 -08:00
..
cli fix non-zero exit code on missing role file (#19002) 2017-02-14 17:57:06 +01:00
compat Fix typo when choosing KqueueSelector 2017-02-06 08:46:58 -08:00
config
errors adds feature to all modules to be run locally (#18763) 2016-12-15 15:47:29 -05:00
executor code clean of old code from network modules updates (#21469) 2017-02-15 12:46:30 -05:00
galaxy PEP 8 E111 & E114 cleanup. (#20838) 2017-01-30 15:01:47 -08:00
inventory Use a custom id generator over uuid4 2017-02-10 14:38:38 -06:00
module_utils refactors junos modules to support persistent socket connections (#21365) 2017-02-16 10:53:03 -05:00
modules fix failing fail_json call in postgresql_schema (#21495) 2017-02-16 11:26:40 -08:00
parsing more cleanup from net_command module that is abandoned for 2.3 (#21497) 2017-02-15 20:38:57 -05:00
playbook delegate_to is a string 2017-02-10 20:07:49 -05:00
plugins refactors junos modules to support persistent socket connections (#21365) 2017-02-16 10:53:03 -05:00
template Also clean template data even if marked unsafe 2017-02-10 10:08:55 -06:00
utils New module: cnos_vlan and various utility files (#21107) 2017-02-16 08:11:39 +00:00
vars Fix bug introduced in 0df3767 regarding undefined entries in HostVars 2017-02-15 16:22:31 -06:00
__init__.py
constants.py more cleanup from net_command module that is abandoned for 2.3 (#21497) 2017-02-15 20:38:57 -05:00
release.py