mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
synchronize: explicitly set the executable for localhost
Otherwise the executable for the destination is also used on the local machine and this might not exist. Fixes: #22867
This commit is contained in:
parent
fb48c45adf
commit
7a00f28804
1 changed files with 14 additions and 0 deletions
|
@ -274,6 +274,20 @@ class ActionModule(ActionBase):
|
|||
localhost_shell = os.path.basename(C.DEFAULT_EXECUTABLE)
|
||||
self._play_context.shell = localhost_shell
|
||||
|
||||
# Unike port, there can be only one executable
|
||||
localhost_executable = None
|
||||
for host in C.LOCALHOST:
|
||||
localhost_vars = task_vars['hostvars'].get(host, {})
|
||||
for executable_var in MAGIC_VARIABLE_MAPPING['executable']:
|
||||
localhost_executable = localhost_vars.get(executable_var, None)
|
||||
if localhost_executable:
|
||||
break
|
||||
if localhost_executable:
|
||||
break
|
||||
else:
|
||||
localhost_executable = C.DEFAULT_EXECUTABLE
|
||||
self._play_context.executable = localhost_executable
|
||||
|
||||
new_connection = connection_loader.get('local', self._play_context, new_stdin)
|
||||
self._connection = new_connection
|
||||
self._override_module_replaced_vars(task_vars)
|
||||
|
|
Loading…
Reference in a new issue