Add host ssh keys to known hosts

When creating the inventory file, perform an ssh keyscan on each
host and add it to the known_hosts file for the job.

Change-Id: If4b362edf9a1ef280e1a8261b91a73ba92932d18
This commit is contained in:
James E. Blair 2017-02-21 15:03:24 -05:00
parent 14e0bb2ec5
commit 6c0978c2d1
1 changed files with 5 additions and 0 deletions

View File

@ -770,6 +770,11 @@ class AnsibleJob(object):
for k, v in host_vars.items():
inventory.write('%s=%s' % (k, v))
inventory.write('\n')
if 'ansible_host' in host_vars:
os.system("ssh-keyscan %s >> %s" % (
host_vars['ansible_host'],
self.jobdir.known_hosts))
with open(self.jobdir.vars, 'w') as vars_yaml:
zuul_vars = dict(zuul=args['zuul'])
vars_yaml.write(