From 367c3c43ff205e0263cbaa0637ba068d0d2bf787 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sat, 13 Feb 2021 11:09:40 +0100 Subject: [PATCH] Make selective callback work with ansible-core 2.11. (#1807) --- changelogs/fragments/selective-core-2.11.yml | 2 ++ plugins/callback/selective.py | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/selective-core-2.11.yml diff --git a/changelogs/fragments/selective-core-2.11.yml b/changelogs/fragments/selective-core-2.11.yml new file mode 100644 index 0000000000..994e555c7c --- /dev/null +++ b/changelogs/fragments/selective-core-2.11.yml @@ -0,0 +1,2 @@ +bugfixes: +- "selective callback plugin - adjust import so that the plugin also works with ansible-core 2.11 (https://github.com/ansible-collections/community.general/pull/1807)." diff --git a/plugins/callback/selective.py b/plugins/callback/selective.py index e46391d099..71620c18c4 100644 --- a/plugins/callback/selective.py +++ b/plugins/callback/selective.py @@ -41,7 +41,16 @@ import difflib from ansible import constants as C from ansible.plugins.callback import CallbackBase from ansible.module_utils._text import to_text -from ansible.utils.color import codeCodes + +try: + codeCodes = C.COLOR_CODES +except AttributeError: + # This constant was moved to ansible.constants in + # https://github.com/ansible/ansible/commit/1202dd000f10b0e8959019484f1c3b3f9628fc67 + # (will be included in ansible-core 2.11.0). For older Ansible/ansible-base versions, + # we include from the original location. + from ansible.utils.color import codeCodes + DONT_COLORIZE = False COLORS = {