Can I print a warning message from Ansible? Like as Ansible does for an internal warning:
[WARNING]: Ignoring invalid attribute: xx
The targeted use are warning, that are not an error, so they should not end the playbook execution, but they should be clearly visible (in standard Ansible purple color).
Example usage:
Based on your question it seems like you may want to fail the playbook if you don't trust the supplied URL but to answer your question about generating
[WARNING]: <supplied text>
messages the only way I know of to do this is by either your own ansible module or by a plugin.
Your module or plugin would make the URL comparison you described and issue an appropriate message.
In an ansible module the module
object that you create has a warn
function that you call like:
module.warn('your text')
In a plugin, your code will generate a Display
object and that object will have a warning
function that you call like:
display.warning('your text')
.
If your goal is simply to have an ansible purple warning message vs what you can generate via the debug
module this seems like a lot of work.