Skip to content

Commit 9e0dad2

Browse files
committed
ansible_mitogen: Templated SSH host key checking
refs #1083
1 parent 9189c01 commit 9e0dad2

File tree

4 files changed

+5
-6
lines changed

4 files changed

+5
-6
lines changed

ansible_mitogen/transport_config.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -500,12 +500,7 @@ def python_path(self, rediscover_python=False):
500500
rediscover_python=rediscover_python)
501501

502502
def host_key_checking(self):
503-
def candidates():
504-
yield self._connection.get_task_var('ansible_ssh_host_key_checking')
505-
yield self._connection.get_task_var('ansible_host_key_checking')
506-
yield C.HOST_KEY_CHECKING
507-
val = next((v for v in candidates() if v is not None), True)
508-
return boolean(val)
503+
return self._connection_option('host_key_checking')
509504

510505
def private_key_file(self):
511506
return self._connection_option('private_key_file')

docs/changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ In progress (unreleased)
2525
on SSH key ``mitogen__has_sudo_pubkey.key`` during Ansible tests.
2626
* :gh:issue:`1083` :mod:`ansible_mitogen`: Templated SSH private key file
2727
(e.g. ``ansible_private_key_file``).
28+
* :gh:issue:`1083` :mod:`ansible_mitogen`: Templated SSH host key checking
29+
(e.g. ``ansible_host_key_checking``, ``ansible_ssh_host_key_checking``).
2830

2931

3032
v0.3.16 (2024-11-05)

tests/ansible/hosts/default.hosts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ ansible_host=localhost
4343
ansible_user="{{ lookup('pipe', 'whoami') }}"
4444

4545
[tt_targets_inventory]
46+
tt-host-key-checking ansible_host_key_checking="{{ 'false' | trim }}" ansible_password=has_sudo_nopw_password ansible_user=mitogen__has_sudo_nopw
4647
tt-password ansible_password="{{ 'has_sudo_nopw_password' | trim }}" ansible_user=mitogen__has_sudo_nopw
4748
tt-port ansible_password=has_sudo_nopw_password ansible_port="{{ 22 | int }}" ansible_user=mitogen__has_sudo_nopw
4849
tt-private-key-file ansible_private_key_file="{{ git_basedir }}/tests/data/docker/mitogen__has_sudo_pubkey.key" ansible_user=mitogen__has_sudo_pubkey

tests/ansible/templates/test-targets.j2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ ansible_python_interpreter={{ tt.python_path }}
7171
ansible_user=mitogen__has_sudo_nopw
7272

7373
[tt_targets_inventory]
74+
tt-host-key-checking ansible_host_key_checking="{{ '{{' }} 'false' | trim {{ '}}' }}" ansible_password=has_sudo_nopw_password ansible_port={{ tt.port }} ansible_user=mitogen__has_sudo_nopw
7475
tt-password ansible_password="{{ '{{' }} 'has_sudo_nopw_password' | trim {{ '}}' }}" ansible_port={{ tt.port }} ansible_user=mitogen__has_sudo_nopw
7576
tt-port ansible_password=has_sudo_nopw_password ansible_port="{{ '{{' }} {{ tt.port }} | int {{ '}}' }}" ansible_user=mitogen__has_sudo_nopw
7677
tt-private-key-file ansible_port={{ tt.port }} ansible_private_key_file="{{ '{{' }} git_basedir {{ '}}' }}/tests/data/docker/mitogen__has_sudo_pubkey.key" ansible_user=mitogen__has_sudo_pubkey

0 commit comments

Comments
 (0)