|
67 | 67 | import ansible.constants as C
|
68 | 68 |
|
69 | 69 | from ansible.module_utils.six import with_metaclass
|
| 70 | +from ansible.module_utils.parsing.convert_bool import boolean |
70 | 71 |
|
71 | 72 | # this was added in Ansible >= 2.8.0; fallback to the default interpreter if necessary
|
72 | 73 | try:
|
@@ -245,6 +246,12 @@ def python_path(self):
|
245 | 246 | Path to the Python interpreter on the target machine.
|
246 | 247 | """
|
247 | 248 |
|
| 249 | + @abc.abstractmethod |
| 250 | + def host_key_checking(self): |
| 251 | + """ |
| 252 | + Whether or not to check the keys of the target machine |
| 253 | + """ |
| 254 | + |
248 | 255 | @abc.abstractmethod
|
249 | 256 | def private_key_file(self):
|
250 | 257 | """
|
@@ -466,6 +473,14 @@ def python_path(self, rediscover_python=False):
|
466 | 473 | action=self._action,
|
467 | 474 | rediscover_python=rediscover_python)
|
468 | 475 |
|
| 476 | + def host_key_checking(self): |
| 477 | + def candidates(): |
| 478 | + yield self._connection.get_task_var('ansible_ssh_host_key_checking') |
| 479 | + yield self._connection.get_task_var('ansible_host_key_checking') |
| 480 | + yield C.HOST_KEY_CHECKING |
| 481 | + val = next((v for v in candidates() if v is not None), True) |
| 482 | + return boolean(val) |
| 483 | + |
469 | 484 | def private_key_file(self):
|
470 | 485 | return self._play_context.private_key_file
|
471 | 486 |
|
@@ -692,6 +707,14 @@ def python_path(self, rediscover_python=False):
|
692 | 707 | action=self._action,
|
693 | 708 | rediscover_python=rediscover_python)
|
694 | 709 |
|
| 710 | + def host_key_checking(self): |
| 711 | + def candidates(): |
| 712 | + yield self._host_vars.get('ansible_ssh_host_key_checking') |
| 713 | + yield self._host_vars.get('ansible_host_key_checking') |
| 714 | + yield C.HOST_KEY_CHECKING |
| 715 | + val = next((v for v in candidates() if v is not None), True) |
| 716 | + return boolean(val) |
| 717 | + |
695 | 718 | def private_key_file(self):
|
696 | 719 | # TODO: must come from PlayContext too.
|
697 | 720 | return (
|
|
0 commit comments