Skip host key checking if host keys are missing
If nodepool doesn't send any host keys, we need to not attempt to check them on the zuul side. Nodepool can omit them if host key checking is disabled, which is necessary in some circumstances. Change-Id: Ib35a9d4c9911fe13afabf089707efcc761fffc74
This commit is contained in:
parent
18026465d6
commit
67e87e28e0
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
features:
|
||||
- |
|
||||
Host key checking is now disabled for a host in the generated
|
||||
Ansible inventory if ``host-key-checking`` is set to ``False``
|
||||
in the corresponding nodepool config.
|
|
@ -459,6 +459,18 @@ class TestAnsibleJob(ZuulTestCase):
|
|||
})[0]['host_keys']
|
||||
self.assertEqual(keys[0], '[localhost]:22022 fake-host-key')
|
||||
|
||||
# Test with no host keys
|
||||
node['host_keys'] = []
|
||||
host = self.test_job.getHostList({'nodes': [node],
|
||||
'host_vars': {},
|
||||
'vars': {},
|
||||
'groups': [],
|
||||
})[0]
|
||||
self.assertEqual(host['host_keys'], [])
|
||||
self.assertEqual(
|
||||
host['host_vars']['ansible_ssh_common_args'],
|
||||
'-o StrictHostKeyChecking=false')
|
||||
|
||||
|
||||
class TestExecutorHostname(ZuulTestCase):
|
||||
config_file = 'zuul-executor-hostname.conf'
|
||||
|
|
|
@ -1587,6 +1587,9 @@ class AnsibleJob(object):
|
|||
host_keys.append("[%s]:%s %s" % (ip, port, key))
|
||||
else:
|
||||
host_keys.append("%s %s" % (ip, key))
|
||||
if not node.get('host_keys'):
|
||||
host_vars['ansible_ssh_common_args'] = \
|
||||
'-o StrictHostKeyChecking=false'
|
||||
|
||||
hosts.append(dict(
|
||||
name=name,
|
||||
|
|
Loading…
Reference in New Issue