community.general/lib/ansible/modules
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
..
cloud [cloud] module docker_image: print output on failure (#20757) 2017-02-16 09:47:18 -05:00
clustering Update validate-modules (#20932) 2017-02-02 11:45:22 -08:00
commands YAML fixes for examples in additional modules 2017-02-15 13:01:43 -08:00
crypto Update validate-modules (#20932) 2017-02-02 11:45:22 -08:00
database fix failing fail_json call in postgresql_schema (#21495) 2017-02-16 11:26:40 -08:00
files Validate EXAMPLES as YAML 2017-02-15 13:01:43 -08:00
identity IPA: Remove duplicated code and fix a bug that occurs if empty lists were passed and IPA didn't know the value before (#19210) 2017-02-08 14:16:44 +00:00
inventory
messaging no log passwords (#21229) 2017-02-10 15:13:59 -05:00
monitoring Validate EXAMPLES as YAML 2017-02-15 13:01:43 -08:00
network refactors junos modules to support persistent socket connections (#21365) 2017-02-16 10:53:03 -05:00
notification Validate EXAMPLES as YAML 2017-02-15 13:01:43 -08:00
packaging YAML fixes for examples in additional modules 2017-02-15 13:01:43 -08:00
remote_management Validate EXAMPLES as YAML 2017-02-15 13:01:43 -08:00
source_control Avoid having module documentation links to itself (#21329) 2017-02-13 14:02:34 +00:00
storage YAML fixes for examples in additional modules 2017-02-15 13:01:43 -08:00
system Validate EXAMPLES as YAML 2017-02-15 13:01:43 -08:00
utilities the return of reset_connection 2017-02-16 10:49:57 -05:00
web_infrastructure Validate EXAMPLES as YAML 2017-02-15 13:01:43 -08:00
windows win_regmerge: Clean up parameter handling (#21388) 2017-02-16 12:41:59 +00:00
__init__.py Re-adding the init py for modules 2016-12-08 11:35:20 -05:00