15

I know this question has been asked multiple times but I didn't find the answer on those other questions.

Here an Image to illustrate my point:

enter image description here

Can you read the blue line without squinting? No? Me neither.

I am running an ansible playbook in full verbose mode and need to read those logs with a playbook of 50+ tasks.

Can anyone explain how can I change those colors?

Questions I looked at where I didn't figure out a solution:

8
  • 2
    blue over the background shall be visible, although in this case is isn't. Do not try to use shell escapes to change the colours. You need to configure the blue color in your terminal emulator to something more visible.
    – grochmal
    Jul 11, 2016 at 15:24
  • @grochmal thanks for the input. How can I do that? Is it LS_Colors or with tput or..... ?
    – Jose Luis
    Jul 11, 2016 at 15:30
  • Which terminal emulator are you using?
    – derobert
    Jul 11, 2016 at 15:32
  • @derobert Kitty
    – Jose Luis
    Jul 11, 2016 at 15:32
  • 1
    halyph.blogspot.com/2013/01/custom-puttykitty-color-scheme.html ... looks like you should have a settings entry to change the colors. (Really probably off-topic here, at least if editing the KiTTY config turns out to be the answer).
    – derobert
    Jul 11, 2016 at 15:35

5 Answers 5

19

You can specify the color to use in ansible (at least you can with ansible 2.3.1.0). Open ansible.cfg and go to the section that says [colors] You should see something like this

[colors]
#highlight = white
#verbose = blue
verbose = green
#warn = bright purple
#error = red
#debug = dark gray
#deprecate = purple
#skip = cyan
#unreachable = red
#ok = green
#changed = yellow
#diff_add = green
#diff_remove = red
#diff_lines = cyan

Just uncomment the text type you want to change and specify the color you want.

1
  • Anyone have a recommendation for settings of a black screen?
    – anthony
    Nov 28, 2022 at 1:58
6

If you are using putty as ssh client, you can simply change its appearance settings.

Change Settings -> Window -> Colours. In the box titled 'Select a colour to adjust:', select 'ANSI Blue' to change the color.

1
4

Most applications stick to 16 colors (8 dark colors and 8 bright colors) known as ANSI colors, because that's the common denominator supported by almost all terminals. The ANSI standard doesn't specify the exact shade, it just says “black”, “blue”, “red”, etc. The default blue shade is often a pure blue that is hard to read on a black background on an RGB monitor, but good terminal emulators let you configure the colors. Adding a little bit of red and green into the color is typically enough to make it readable but still distinct.

With xterm, PuTTY, and other compatible terminals, you can configure the colors from an application running inside the terminal by emitting the proper escape sequence. Try running this in the terminal before you start the application:

## Set the blue hue (color 4) to CornflowerBlue
printf '\e]4;4;#6495ed\a'

If you run bash when you open the terminal, put this in your .bashrc. If the ansible application opens a terminal on its own, make it print this escape sequence to the terminal.

Alternatively, many terminals let you configure the colors in their configuration, for example through X resources in Xterm. Check the documentation of your terminal emulator.

1
  • going straight in my .bashrc file
    – lsh
    Aug 2, 2017 at 11:39
3

The official documentation how to change each color in ansible can be found here: https://docs.ansible.com/ansible/latest/reference_appendices/config.html

If a dark background is used mostly the verbose blue output can not be read.

I use for this in ansible.cfg

[colors]
verbose: bright blue
2

Nope, never have been able to read blue on black (and life is far too short to fiddle with colour customizations in every terminal or console combination I might use) so I disable colors by default. With xterm, an .Xdefaults entry of:

XTerm*colorMode:false

does wonders; otherwise, without a means to kill the colors in the terminal, application specific hacks may be necessary; a quick kluge is to use a shell function and pipe the output to cat which disconnects ansible from the terminal and may cause it to not spam colors:

function ansible-playbook {
    command ansible-playbook "$@" | cat
}

Another kluge is to fiddle with the TERM, e.g. TERM=vt220 ansible-playbook ... (this tends to work on older systems, but the color spam alas is present with TERM=vt220 on modern systems and changing the TERM without knowing what you're getting into is probably a bad idea).

However! From some spelunking under the ansible sources, ansible is not buggy and does provide an ANSIBLE_NOCOLOR=1 environment variable:

ANSIBLE_NOCOLOR=1 ansible-playbook ...
2
  • 1
    OP's not using xterm, so this answer is not useful. Jul 11, 2016 at 20:31
  • 1
    @ThomasDickey please explain, in detail, how ANSIBLE_NOCOLOR=1 ansible... is not useful on a console.
    – thrig
    Jul 12, 2016 at 13:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .