Skip to content

Commit eaa990a

Browse files
committed
ansible: add mitogen_ssh_compression variable.
1 parent 2c7af9f commit eaa990a

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

Diff for: ansible_mitogen/connection.py

+10
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ def optional_int(value):
7070
return None
7171

7272

73+
def default(value, default):
74+
"""
75+
Return `default` is `value` is :data:`None`, otherwise return `value`.
76+
"""
77+
if value is None:
78+
return default
79+
return value
80+
81+
7382
def _connect_local(spec):
7483
"""
7584
Return ContextService arguments for a local connection.
@@ -103,6 +112,7 @@ def _connect_ssh(spec):
103112
'check_host_keys': check_host_keys,
104113
'hostname': spec.remote_addr(),
105114
'username': spec.remote_user(),
115+
'compression': default(spec.mitogen_ssh_compression(), True),
106116
'password': spec.password(),
107117
'port': spec.port(),
108118
'python_path': spec.python_path(),

Diff for: ansible_mitogen/transport_config.py

+12
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,12 @@ def mitogen_ssh_debug_level(self):
273273
The SSH debug level.
274274
"""
275275

276+
@abc.abstractmethod
277+
def mitogen_ssh_compression(self):
278+
"""
279+
Whether SSH compression is enabled.
280+
"""
281+
276282
@abc.abstractmethod
277283
def extra_args(self):
278284
"""
@@ -398,6 +404,9 @@ def mitogen_machinectl_path(self):
398404
def mitogen_ssh_debug_level(self):
399405
return self._connection.get_task_var('mitogen_ssh_debug_level')
400406

407+
def mitogen_ssh_compression(self):
408+
return self._connection.get_task_var('mitogen_ssh_compression')
409+
401410
def extra_args(self):
402411
return self._connection.get_extra_args()
403412

@@ -577,5 +586,8 @@ def mitogen_machinectl_path(self):
577586
def mitogen_ssh_debug_level(self):
578587
return self._host_vars.get('mitogen_ssh_debug_level')
579588

589+
def mitogen_ssh_compression(self):
590+
return self._host_vars.get('mitogen_ssh_compression')
591+
580592
def extra_args(self):
581593
return [] # TODO

Diff for: docs/ansible.rst

+4
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,10 @@ except connection delegation is supported.
901901
* ``ssh_args``, ``ssh_common_args``, ``ssh_extra_args``
902902
* ``mitogen_ssh_debug_level``: integer between `0..3` indicating the SSH client
903903
debug level. Ansible must also be run with '-vvv' to view the output.
904+
* ``mitogen_ssh_compression``: :data:`True` to enable SSH compression,
905+
otherwise :data:`False`. This will change to off by default in a future
906+
release. If you are targetting many hosts on a fast network, please consider
907+
disabling SSH compression.
904908

905909

906910
Debugging

0 commit comments

Comments
 (0)