mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 11:21:25 -07: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:
parent
2077e32ddd
commit
6117e1946e
4 changed files with 59 additions and 8 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue