From 7b74de069cfeb5f1ec1b9f3d1784e1c744d93488 Mon Sep 17 00:00:00 2001 From: akire0ne <80416563+akire0ne@users.noreply.github.com> Date: Fri, 9 Aug 2024 15:26:21 +0100 Subject: fix: `COLOR_INCLUDED` to colorize `included` output (#83711) adds color included configuration and applies to include message Co-authored-by: Achille Myette --- lib/ansible/config/base.yml | 8 ++++++++ lib/ansible/plugins/callback/default.py | 2 +- lib/ansible/utils/display.py | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/ansible/config/base.yml b/lib/ansible/config/base.yml index 6fabaee081..a6435cc716 100644 --- a/lib/ansible/config/base.yml +++ b/lib/ansible/config/base.yml @@ -304,6 +304,14 @@ COLOR_HIGHLIGHT: env: [{name: ANSIBLE_COLOR_HIGHLIGHT}] ini: - {key: highlight, section: colors} +COLOR_INCLUDED: + name: Color for 'included' task status + default: cyan + description: Defines the color to use when showing 'Included' task status. + env: [{name: ANSIBLE_COLOR_INCLUDED}] + ini: + - {key: included, section: colors} + version_added: '2.18' COLOR_OK: name: Color for 'ok' task status default: green diff --git a/lib/ansible/plugins/callback/default.py b/lib/ansible/plugins/callback/default.py index c96d9ababc..4a0bf0d05b 100644 --- a/lib/ansible/plugins/callback/default.py +++ b/lib/ansible/plugins/callback/default.py @@ -293,7 +293,7 @@ class CallbackModule(CallbackBase): label = self._get_item_label(included_file._vars) if label: msg += " => (item=%s)" % label - self._display.display(msg, color=C.COLOR_SKIP) + self._display.display(msg, color=C.COLOR_INCLUDED) def v2_playbook_on_stats(self, stats): self._display.banner("PLAY RECAP") diff --git a/lib/ansible/utils/display.py b/lib/ansible/utils/display.py index 2379aecf6d..e514155e16 100644 --- a/lib/ansible/utils/display.py +++ b/lib/ansible/utils/display.py @@ -172,6 +172,7 @@ if getattr(C, 'DEFAULT_LOG_PATH'): color_to_log_level = {C.COLOR_DEBUG: logging.DEBUG, C.COLOR_VERBOSE: logging.INFO, C.COLOR_OK: logging.INFO, + C.COLOR_INCLUDED: logging.INFO, C.COLOR_CHANGED: logging.INFO, C.COLOR_SKIP: logging.WARNING, C.COLOR_DEPRECATE: logging.WARNING, -- cgit v1.2.3