use ansible_ssh_host_key_checking, fixup

Philippe Kueck 4 weeks ago
parent 8e7e785ac4
commit efd51c16b9
No known key found for this signature in database
GPG Key ID: E10E57D62DB57A3B

@ -119,12 +119,14 @@ def _connect_ssh(spec):
"""
Return ContextService arguments for an SSH connection.
"""
check_host_keys = spec.mitogen_ssh_host_key_checking()
check_host_keys = spec.ansible_ssh_host_key_checking()
if check_host_keys is None:
if C.HOST_KEY_CHECKING:
check_host_keys = 'enforce'
else:
check_host_keys = 'ignore'
else:
check_host_keys = ('ignore', 'enforce')[check_host_keys]
# #334: tilde-expand private_key_file to avoid implementation difference
# between Python and OpenSSH.

@ -67,6 +67,7 @@ import ansible.utils.shlex
import ansible.constants as C
from ansible.module_utils.six import with_metaclass
from ansible.module_utils.parsing.convert_bool import boolean
# this was added in Ansible >= 2.8.0; fallback to the default interpreter if necessary
try:
@ -386,7 +387,7 @@ class Spec(with_metaclass(abc.ABCMeta, object)):
"""
@abc.abstractmethod
def mitogen_ssh_host_key_checking(self):
def ansible_ssh_host_key_checking(self):
"""
Whether or not to check the ssh hostkeys
"""
@ -570,8 +571,15 @@ class PlayContextSpec(Spec):
def mitogen_ssh_compression(self):
return self._connection.get_task_var('mitogen_ssh_compression')
def mitogen_ssh_host_key_checking(self):
return self._connection.get_task_var('mitogen_ssh_host_key_checking')
def ansible_ssh_host_key_checking(self):
tmp = [boolean(x) for x in list(
filter(lambda x:x is not None, (
self._connection.get_task_var('ansible_ssh_host_key_checking'),
self._connection.get_task_var('ansible_host_key_checking')
)))]
if not tmp:
return None
return any(tmp)
def extra_args(self):
return self._connection.get_extra_args()

@ -1047,8 +1047,6 @@ Like the :ans:conn:`ssh` except connection delegation is supported.
to 10.
* ``mitogen_ssh_keepalive_interval``: integer seconds delay between keepalive
messages. Defaults to 30.
* ``mitogen_ssh_host_key_checking``: `accept`, `enforce` or `ignore` the
remote's ssh host key
Debugging

@ -22,8 +22,7 @@ Unreleased
----------
* :gh:issue:`952` Fix Ansible `--ask-become-pass`, add test coverage
* :gh:issue:`1066` Introduce `mitogen_ssh_host_key_checking` to somehow mimic
`ansible_host_key_checking`
* :gh:issue:`1066` Fix `ansible_ssh_host_key_checking`
v0.3.7 (2024-04-08)

Loading…
Cancel
Save