From 68709ecda261c62f011c9b68e0004e4b7b14a48c Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Thu, 3 Aug 2023 18:44:20 -0400 Subject: [PATCH] fix networking path (#81295) (#81353) * now uses class property instead of only relying on network_os variable --------- Co-authored-by: Martin Krizek (cherry picked from commit 6db006a5fa18b710e5ad0bc90e5ea5494a6b68c2) --- changelogs/fragments/forced_local+fix+.yml | 2 ++ lib/ansible/executor/task_executor.py | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/forced_local+fix+.yml diff --git a/changelogs/fragments/forced_local+fix+.yml b/changelogs/fragments/forced_local+fix+.yml new file mode 100644 index 00000000000..4186453bfb5 --- /dev/null +++ b/changelogs/fragments/forced_local+fix+.yml @@ -0,0 +1,2 @@ +bugfixes: + - core will now also look at the connection plugin to force 'local' interpreter for networking path compatibility as just ansible_network_os could be misleading. diff --git a/lib/ansible/executor/task_executor.py b/lib/ansible/executor/task_executor.py index a4200c0848c..116cd9f49fa 100644 --- a/lib/ansible/executor/task_executor.py +++ b/lib/ansible/executor/task_executor.py @@ -609,9 +609,8 @@ class TaskExecutor: display.vvvv('local domain socket path is %s' % socket_path, host=self._play_context.remote_addr) setattr(self._connection, '_socket_path', socket_path) - # TODO: eventually remove this block as this should be a 'consequence' of 'forced_local' modules # special handling for python interpreter for network_os, default to ansible python unless overridden - if 'ansible_network_os' in cvars and 'ansible_python_interpreter' not in cvars: + if 'ansible_python_interpreter' not in cvars and 'ansible_network_os' in cvars and getattr(self._connection, '_remote_is_local', False): # this also avoids 'python discovery' cvars['ansible_python_interpreter'] = sys.executable