From 6db006a5fa18b710e5ad0bc90e5ea5494a6b68c2 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Thu, 27 Jul 2023 10:59:55 -0400 Subject: [PATCH] fix networking path (#81295) * now uses class property instead of only relying on network_os variable --------- Co-authored-by: Martin Krizek --- changelogs/fragments/forced_local+fix+.yml | 2 ++ lib/ansible/executor/task_executor.py | 4 ++-- 2 files changed, 4 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 784f80a5a1c..47141f06984 100644 --- a/lib/ansible/executor/task_executor.py +++ b/lib/ansible/executor/task_executor.py @@ -595,9 +595,9 @@ class TaskExecutor: # feed back into pc to ensure plugins not using get_option can get correct value self._connection._play_context = self._play_context.set_task_and_variable_override(task=self._task, variables=vars_copy, templar=templar) - # TODO: eventually remove this block as this should be a 'consequence' of 'forced_local' modules + # TODO: eventually remove this block as this should be a 'consequence' of 'forced_local' modules, right now rely on remote_is_local connection # 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