perf: ansible forks to 20

This commit is contained in:
feng
2026-06-26 17:16:29 +08:00
parent 0a436de927
commit 5922449b3a
2 changed files with 14 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
[defaults]
forks = 10
forks = 20
host_key_checking = False
library = /opt/jumpserver/apps/libs/ansible/modules:./modules
timeout = 65

View File

@@ -64,9 +64,9 @@ def raise_timeout(name=''):
signal.signal(signal.SIGALRM, handler)
signal.alarm(timeout)
return func(self, *args, **kwargs)
except Exception as error:
signal.alarm(0)
raise error
finally:
if timeout > 0:
signal.alarm(0)
return wrapper
@@ -122,13 +122,22 @@ class SSHClient:
def get_connect_params(self):
p = self.module.params
connect_timeout = p.get('recv_timeout', 60)
params = {
'allow_agent': False,
'look_for_keys': False,
'hostname': p['login_host'],
'port': p['login_port'],
'key_filename': p['login_private_key_path'] or None
'key_filename': p['login_private_key_path'] or None,
}
if connect_timeout:
# Keep Paramiko connect/auth/banner waits bounded by the same
# timeout budget as command receive so a bad host returns promptly.
params.update(
timeout=connect_timeout,
auth_timeout=connect_timeout,
banner_timeout=connect_timeout,
)
if p['become']:
params['username'] = p['become_user']