Q:

How to control color for an Ansible message (foreground and background)?

Looking at https://docs.ansible.com/ansible/latest/modules/debug_module.html there is no mention of how to control the foreground and background colors for text. Is it possible to control that?

A:

It is possible to configure colors in the configuration file and/or in the environment variable.
For example for debug
> cat ansible.cfg
[defaults]
inventory = $PWD/hosts
...
[colors]
debug = red
deprecate = bright purple
changed = purple

or
> set | grep ANSIBLE_COLOR_DEBUG
ANSIBLE_COLOR_DEBUG=red

