mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 05:12:45 +00:00
Check controlpersist (#17443)
* Add a new config option to cache the check for controlpersist on the control machine. Fixes #15844 * Remove the option and make the behavior the default * Make the check for controlpersist cache its status per-ssh executable
This commit is contained in:
@@ -36,6 +36,7 @@ from ansible.playbook.task import Task
|
||||
from ansible.template import Templar
|
||||
from ansible.utils.encrypt import key_for_hostname
|
||||
from ansible.utils.listify import listify_lookup_plugin_terms
|
||||
from ansible.utils.ssh_functions import check_for_controlpersist
|
||||
from ansible.vars.unsafe_proxy import UnsafeProxy, wrap_var
|
||||
|
||||
try:
|
||||
@@ -666,14 +667,7 @@ class TaskExecutor:
|
||||
conn_type = "paramiko"
|
||||
else:
|
||||
# see if SSH can support ControlPersist if not use paramiko
|
||||
try:
|
||||
ssh_executable = C.ANSIBLE_SSH_EXECUTABLE
|
||||
cmd = subprocess.Popen([ssh_executable, '-o', 'ControlPersist'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
(out, err) = cmd.communicate()
|
||||
err = to_text(err)
|
||||
if u"Bad configuration option" in err or u"Usage:" in err:
|
||||
conn_type = "paramiko"
|
||||
except OSError:
|
||||
if not check_for_controlpersist(self._play_context.ssh_executable):
|
||||
conn_type = "paramiko"
|
||||
|
||||
connection = self._shared_loader_obj.connection_loader.get(conn_type, self._play_context, self._new_stdin)
|
||||
|
||||
Reference in New Issue
Block a user