From 4627c30b2e269a91a5f81f7d4178e9545026c517 Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde Date: Tue, 4 May 2021 21:31:49 +0530 Subject: [PATCH] interpreter_discovery: Hide warning in auto_silent (#74509) Hide warning "No python interpreters" in auto_silent mode. Fixes: #74274 Signed-off-by: Abhijeet Kasurde --- changelogs/fragments/74274_interpreter_discovery.yml | 2 ++ lib/ansible/executor/interpreter_discovery.py | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/74274_interpreter_discovery.yml diff --git a/changelogs/fragments/74274_interpreter_discovery.yml b/changelogs/fragments/74274_interpreter_discovery.yml new file mode 100644 index 00000000000..0707bdb35bf --- /dev/null +++ b/changelogs/fragments/74274_interpreter_discovery.yml @@ -0,0 +1,2 @@ +bugfixes: +- interpreter_discovery - hide warning 'No python interpreters...' when ANSIBLE_PYTHON_INTERPRETER=auto_silent (https://github.com/ansible/ansible/issues/74274). diff --git a/lib/ansible/executor/interpreter_discovery.py b/lib/ansible/executor/interpreter_discovery.py index d387180b813..218920a1228 100644 --- a/lib/ansible/executor/interpreter_discovery.py +++ b/lib/ansible/executor/interpreter_discovery.py @@ -82,7 +82,9 @@ def discover_interpreter(action, interpreter_name, discovery_mode, task_vars): display.debug(u"found interpreters: {0}".format(found_interpreters), host=host) if not found_interpreters: - action._discovery_warnings.append(u'No python interpreters found for host {0} (tried {1})'.format(host, bootstrap_python_list)) + if not is_silent: + action._discovery_warnings.append(u'No python interpreters found for ' + u'host {0} (tried {1})'.format(host, bootstrap_python_list)) # this is lame, but returning None or throwing an exception is uglier return u'/usr/bin/python'