diff --git a/ansible_mitogen/connection.py b/ansible_mitogen/connection.py index 76d4acc02..ec54bd32f 100644 --- a/ansible_mitogen/connection.py +++ b/ansible_mitogen/connection.py @@ -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. diff --git a/ansible_mitogen/transport_config.py b/ansible_mitogen/transport_config.py index dc4516ce3..4fa28c275 100644 --- a/ansible_mitogen/transport_config.py +++ b/ansible_mitogen/transport_config.py @@ -67,6 +67,7 @@ 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 @@ def mitogen_ssh_compression(self): """ @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 @@ def mitogen_ssh_debug_level(self): 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() diff --git a/docs/ansible_detailed.rst b/docs/ansible_detailed.rst index 781cc48c2..b395bc25e 100644 --- a/docs/ansible_detailed.rst +++ b/docs/ansible_detailed.rst @@ -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 diff --git a/docs/changelog.rst b/docs/changelog.rst index 89aba5a33..93dfd8f25 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -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)