Import module error: ansible.utils.display

Hi, all!
I’m trying to import:
117 from ansible.utils.display import Display

in my new module, placed in lib/ansible/modules/database/postgresql/

But during tests and execution the following error occurred:
Sanity check using import with Python 2.7
ERROR: Found 1 import issue(s) on python 2.7 which need to be resolved:
ERROR: lib/ansible/modules/database/postgresql/postgresql_ping.py:117:0: ImportError: No module named utils.display

Any ideas, why?

This module successfully imported by the same line in lib/ansible/utils/display.py.

I want to add it to display warnings in the shell.

Maybe there is better way to do this.

I’ll be grateful for any ideas, thank you!

Modules cannot import things from outside of ansible.module_utils. As such you cannot use Display in a module.

In addition to that, a module may only output JSON at the end of the execution, via module.fail_json or module.exit_json

You can however use module.warn to send back warnings that will be displayed to the user.

Hello, module.warn() works great. Thank you!

вт, 29 янв. 2019 г. в 17:39, Matt Martz <matt@sivel.net>: